Created
February 13, 2013 23:24
-
-
Save ebot/4949351 to your computer and use it in GitHub Desktop.
My Arduino samples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Ed's Blinker Sample | |
| Turns on two LEDs for five seconds, then off for one second, repeatedly. | |
| The led on pin 11 alternates between red and green indicating if the | |
| circuit is switched on or off. | |
| This is a hack of the default blink example from Arduino. | |
| */ | |
| // Pin 13 has an LED connected on most Arduino boards. | |
| // give it a name: | |
| int led_gnd = 10; | |
| int led_1 = 11; | |
| int led_2 = 12; | |
| int led_3 = 13; | |
| // the setup routine runs once when you press reset: | |
| void setup() { | |
| // initialize the digital pin as an output. | |
| pinMode(led_1, OUTPUT); | |
| pinMode(led_2, OUTPUT); | |
| pinMode(led_3, OUTPUT); | |
| pinMode(led_gnd, OUTPUT); | |
| } | |
| // the loop routine runs over and over again forever: | |
| void loop() { | |
| digitalWrite(led_1, HIGH); // turn the LEDs on (HIGH is the voltage level) | |
| digitalWrite(led_2, HIGH); | |
| digitalWrite(led_3, HIGH); | |
| digitalWrite(led_gnd, LOW); // Grnd pin forces led_1 to be green | |
| delay(5000); // wait for five seconds | |
| digitalWrite(led_1, LOW); // turn the LEDs off by making the voltage LOW | |
| digitalWrite(led_2, LOW); | |
| digitalWrite(led_3, LOW); | |
| digitalWrite(led_gnd, HIGH); // Making the grnd high reverses the current | |
| // turning the led_1 red. | |
| delay(5000); // wait for five second | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment