// Example 01 : Blinking LED from the Arduino Book
#define LED 13 // LED connected to
// digital pin 13
void setup()
{
pinMode(LED, OUTPUT); // sets the digital
// pin as output
}
void loop()
{
digitalWrite(LED, HIGH); // turns the LED on
delay(1000); // waits for a second
digitalWrite(LED, LOW); // turns the LED off
delay(1000); // waits for a second
}
-----------------------------------------
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This code was found in the Arduino Software
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

So the code for making a two led blink pattern, I just used cut and paste to add another LED on pin 12. Otherwise, the code is the same as above.
// 2 Blinking LED's - Modified by Philip Leete
#define First_Led 12 //First_Led is connected to pin 12
#define Second_Led 13 //Second_LED is connected to pin 13
void setup()
{
pinMode(First_Led, OUTPUT); //This sets both leds as outputs
pinMode(Second_Led, OUTPUT);
}
void loop()
{
digitalWrite(First_Led, HIGH); // turns the First LED on
delay(100); // waits for the given time, in miliseconds
digitalWrite(First_Led, LOW); // turns the First LED off
delay(100);
digitalWrite(Second_Led, HIGH); // turns the Second LED on
delay(100);
digitalWrite(Second_Led, LOW); // turns the Second LED off
delay(100);
}
No comments:
Post a Comment