#include <blinker.h>
#include <serialStr.h>
#define PERIOD_MS 1000 // Starting period of 1 sec.
blinker aBLinker; // Auto-blinker. We'll play with it's period.
serialStr comReader; // Reader of serial port and provider of complete c strings from it.
void setup() {
Serial.begin(9600); // Make serial port active.
Serial.println("Type number for new period in ms"); // Wake up user.
aBLinker.setPeriod(PERIOD_MS); // Set up blinking LED.
aBLinker.setPercent(50); // 50% on, 50% off as default.
aBLinker.setOnOff(true); // Make it go.
comReader.setCallback(gotCom); // When we read a string, call this function.
}
// A string cme in from the Serial port. Set period with it here.
void gotCom(char* inStr) {
float period;
period = atof(inStr); // Convert the string to a float.
Serial.print("Setting period to : "); // Tell user.
Serial.print(period,2); //
Serial.println(" ms."); //
aBLinker.setPeriod(period); // Set the % LED on-time.
aBLinker.setPercent(50); // 50% on, 50% off.
}
// Loop, you do what you want in here. Keep the idle() call first.
// Don't use delay(). But you can use sleep(). Works the same. As
// far as you know.
void loop() { idle(); }