
Modifications to Blink example
By: a guest on
Jun 16th, 2010 | syntax:
C | size: 1.25 KB | hits: 462 | expires: Never
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
The circuit:
* LED connected from digital pin 13 to ground.
* Note: On most Arduino boards, there is already an LED on the board
connected to pin 13, so you don't need any extra components for this example.
Modified by Brian Jepson for a webcast
based on an original...
Created 1 June 2005
By David Cuartielles
http://arduino.cc/en/Tutorial/Blink
based on an orginal by H. Barragan for the Wiring i/o board
*/
int ledPin = 13; // LED connected to digital pin 13
int buttonPin = 2; // button connected to digital pin 2
int val = 0; // stores the state of the button
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the button pin as an input
pinMode(buttonPin, INPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
val = digitalRead(buttonPin);
if (val == HIGH) {
digitalWrite(ledPin, HIGH); // set the LED on
} else {
digitalWrite(ledPin, LOW); // set the LED off
}
delay(10);
}