/***** * blink3.ino * Blinks the number of times you type in the Serial Monitor. * Runs on: Arduino Uno rev3 * Created by: Andrew Burton *****/ String count = ""; int yesno = 0; int led = 13; void setup() { Serial.begin(9600); pinMode(led, OUTPUT); digitalWrite(led, LOW); } void loop() { if (Serial.available() > 0) { yesno = 1; char c = Serial.read(); count = count + c; } else { if (yesno == 1) { int cnt = count.toInt(); if (cnt > 0) { Serial.println("Print " + count + " times."); Blinker(cnt); } count = ""; yesno = 0; } } delay(100); } void Blinker(int times) { delay(100); for (int x = 0; x < times; x++) { digitalWrite(led, HIGH); delay(500); digitalWrite(led, LOW); delay(500); } }