iot components callback
This commit is contained in:
parent
d3497b671e
commit
9fa8cbc4b1
10 changed files with 117 additions and 32 deletions
38
Template Project/src/iotdemo.cpp
Normal file
38
Template Project/src/iotdemo.cpp
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue