#include <blinker.h>
#include <serialStr.h>
#define PERIOD_MS 1000
blinker aBLinker; // Auto-blinker. We'll play with it's % time on function.
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 Pulse width %"); // 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 pulse width with it here.
void gotCom(char* inStr) {
float percent;
percent = atof(inStr); // Convert the string to a float.
Serial.print("Setting percent to : "); // Tell user.
Serial.println(percent,2); //
aBLinker.setPercent(percent); // Set the % LED on-time.
}
// 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(); }