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.