// Uses two LEDs for demo purposes // ledPin = LED that will flash the specified number of times // rxPin = LED that will flash once for each serial byte received int ledPin = 9; int rxPin = 8; int b; int n; void setup(){ pinMode(ledPin, OUTPUT); pinMode(rxPin, OUTPUT); Serial.begin(9600); } void loop(){ // Read in the next available byte and blink the rx LED once if(Serial.available() > 0){ b = Serial.read(); Serial.println(b); blink(rxPin, 1, 25); } // Subtract 48 to convert ASCII char to right integer ("1" = 49) n = int(b) - 48; // If number received, flash LED correct number of times if(n > 0) { Serial.print("F"); Serial.println(n); blink(ledPin,n,75); delay(500); } n = 0; b = 0; } void blink(int pin, int count, int ms) { int x; for(x = 0; x < count; x++) { digitalWrite(pin, HIGH); delay(ms); digitalWrite(pin, LOW); delay(ms); } }