View difference between Paste ID: DEMSChTV and
SHOW: | | - or go back to the newest paste.
1-
1+
/*
2
  Blink
3
 
4
 Turns on an LED on for one second, then off for one second, repeatedly.
5
 
6
 The circuit:
7
 * LED connected from digital pin 13 to ground.
8
 
9
 * Note: On most Arduino boards, there is already an LED on the board
10
 connected to pin 13, so you don't need any extra components for this example.
11
 
12
 Modified by Brian Jepson for a webcast
13
 
14
 based on an original...
15
 Created 1 June 2005
16
 By David Cuartielles
17
 
18
 http://arduino.cc/en/Tutorial/Blink
19
 
20
 based on an orginal by H. Barragan for the Wiring i/o board
21
 
22
 */
23
24
int ledPin =  13;    // LED connected to digital pin 13
25
int buttonPin = 2;   // button connected to digital pin 2
26
int val = 0;         // stores the state of the button
27
28
// The setup() method runs once, when the sketch starts
29
void setup()   {                
30
  // initialize the LED pin as an output:
31
  pinMode(ledPin, OUTPUT);     
32
  
33
  // initialize the button pin as an input
34
  pinMode(buttonPin, INPUT);
35
}
36
37
// the loop() method runs over and over again,
38
// as long as the Arduino has power
39
void loop()                     
40
{
41
  val = digitalRead(buttonPin);
42
  if (val == HIGH) {
43
    digitalWrite(ledPin, HIGH);   // set the LED on
44
  } else {
45
    digitalWrite(ledPin, LOW);    // set the LED off
46
  }
47
  delay(10);
48
}