iot components callback

This commit is contained in:
Siwat Sirichai 2023-12-28 13:14:18 +07:00
parent d3497b671e
commit 9fa8cbc4b1
10 changed files with 117 additions and 32 deletions

View file

@ -0,0 +1,38 @@
#include <ESPMegaPRO_OOP.hpp>
// Instantiate ESPMega
ESPMegaPRO espmega = ESPMegaPRO();
void setup()
{
// Initialize ESPMega
espmega.begin();
Serial.println("ESPMega initialized");
}
void loop()
{
// Read all the inputs and print them
for (int i = 0; i < 16; i++)
{
Serial.print("Input ");
Serial.print(i);
Serial.print(": ");
Serial.print(espmega.inputs.digitalRead(i));
Serial.println();
}
// Turn on all the outputs
for (int i = 0; i < 16; i++)
{
espmega.outputs.digitalWrite(i, true);
}
// Wait 1 second
delay(1000);
// Turn off all the outputs
for (int i = 0; i < 16; i++)
{
espmega.outputs.digitalWrite(i, false);
}
// Wait 1 second
delay(1000);
}