]> git.piffa.net Git - arduino/blob - books/ArduinoNextSteps-master/ArduinoNextSteps/sketch_14_01_flashing_1/sketch_14_01_flashing_1.ino
first commit
[arduino] / books / ArduinoNextSteps-master / ArduinoNextSteps / sketch_14_01_flashing_1 / sketch_14_01_flashing_1.ino
1 // sketch_14_01_flashing_1
2
3 const int ledPin = 13;
4 const int switchPin = 5;
5 const int period = 1000;
6
7 boolean flashing = false;
8
9 void setup()
10 {
11   pinMode(ledPin, OUTPUT);
12   pinMode(switchPin, INPUT_PULLUP); 
13 }
14
15 void loop()
16 {
17   if (digitalRead(switchPin) == LOW)
18   {
19     flashing = ! flashing;
20   }
21   if (flashing)
22   {
23     digitalWrite(ledPin, HIGH);
24     delay(period);
25     digitalWrite(ledPin, LOW);
26     delay(period);
27   }    
28 }