/** FlashingLedClass.ino by Matthew Ford, 2020/01/27 (c)2019 Forward Computing and Control Pty. Ltd. NSW, Australia www.forward.com.au */ // this sketch runs on Uno and most other Arduino boards // it uses millisDelay from https://www.forward.com.au/pfod/ArduinoProgramming/TimingDelaysInArduino.html // download and install the millisDelay library https://www.forward.com.au/pfod/ArduinoProgramming/millisDelay.zip #include "millisDelay.h" #include "Toggle.h" // for the flashing methods #include "DebugIO.h" millisDelay increaseTogglingDelay; unsigned long INCREASE_TOGGLING_DELAY_MS = 8000; // stop flashing in 8sec Toggle togglePin_A; // declare two toggle instances one for each pin Toggle togglePin_B; // don't use togglePin_B(); or you will get some odd error msgs. This is a C++ oddity. void setup() { Serial.begin(9600); for (int i = 10; i > 0; i--) { // wait 5 sec to give you time to open the serial Monitor Serial.print(i); Serial.print(' '); delay(500); } Serial.println(); setDebugPtr(&Serial); // initialize debug with the adddress of Serial do this first before calling togglePinInit togglePin_A.togglePinInit(13); // built in led togglePin_A.startTogglingPin(); togglePin_B.togglePinInit(12); // another external led togglePin_B.startTogglingPin(); increaseTogglingDelay.start(INCREASE_TOGGLING_DELAY_MS); } void loop() { togglePin_A.handleTogglingPin(); // check if led should be toggled togglePin_B.handleTogglingPin(); // check if pin should be toggled if (increaseTogglingDelay.justFinished()) { togglePin_A.setTogglingSpeed(100); // toggle pin every 1/10 sec } }