]> git.piffa.net Git - arduino/blob - books/ArduinoNextSteps-master/ArduinoNextSteps/sketch_05_05_narcoleptic_input/sketch_05_05_narcoleptic_input.ino
first commit
[arduino] / books / ArduinoNextSteps-master / ArduinoNextSteps / sketch_05_05_narcoleptic_input / sketch_05_05_narcoleptic_input.ino
1 // sketch_05_05_narcoleptic_input
2 #include <Narcoleptic.h>
3
4 const int ledPin = 13;
5 const int inputPin = 2;
6
7 void setup() 
8 {
9   pinMode(ledPin, OUTPUT);
10   pinMode(inputPin, INPUT_PULLUP);
11 }
12
13 void loop() 
14 {
15   if (digitalRead(inputPin) == LOW)
16   {
17     doSomething();
18   }
19   Narcoleptic.delay(100);
20 }
21
22 void doSomething()
23 {
24   for (int i = 0; i < 20; i++)
25   {
26     digitalWrite(ledPin, HIGH);
27     Narcoleptic.delay(200);
28     digitalWrite(ledPin, LOW);
29     Narcoleptic.delay(200);
30   }
31 }