Danois90:
You could "cheat" and use TPinOutput from TDuino:#include <TDuino.h>
#define LED_PIN_1 3
#define LED_PIN_2 4
TPinOutput led1(LED_PIN_1), led2(LED_PIN_2);
void setup()
{
Serial.begin(9600);
while (!Serial) ;
led1.setup();
led2.setup();
}
void loop()
{
//Loop leds
led1.loop();
led2.loop();
if (Serial.available())
{
int command = Serial.parseInt();
if (command == 1) led1.pulse(100, 1);
else if (command == 2) led2.pulse(100, 1);
}
}
Delay-free and easy! But you may run into trouble with the serial communication if you do not send each serial command with a delimiter (eg. new-line \n) and adjust the sketch to handle this.
This is handy, but how do I go about adding Tduino, as I'm getting this error message:
Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\*Redacted*\Documents\Arduino\blinkwithoutled\blinkwithoutled.ino:1:20: fatal error: TDuino.h: No such file or directory
#include <TDuino.h>
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I'm assuming download the lot and then extract the contents into my arduino installation location?