Created
May 6, 2015 22:01
-
-
Save refriedchicken/9795bdd0ff3ad04509f1 to your computer and use it in GitHub Desktop.
Chip Eye Blink
This file contains 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
// Chip has 3 important pins | |
// Ground (GND) -- plugged into to Arduino GND | |
// Right Eye LED (D10) --> plugged into to Arduino D10 | |
// Left Eye LED (D11) --> plugged into to Arduino D11 | |
// | |
// We need to define Chip's eyes so we can use them in our code | |
int rEye = 10; //define right eye as pin10 on the Arduino | |
int lEye = 11; //define right eye as pin11 on the Arduino | |
// Next we need to initialize the Arduino pins | |
// setup() only runs once when you power on or reset an Arduino | |
void setup(){ | |
pinMode(rEye, OUTPUT); //set right eye for output | |
pinMode(lEye, OUTPUT); //set left eye for output | |
} | |
//loop() runs forever - this is our main code | |
void loop(){ | |
// turn both eyes on. HIGH means set voltage to HIGH | |
digitalWrite(rEye, HIGH); | |
digitalWrite(lEye, HIGH); | |
delay (1000); //wait for 1 second. Delay is set in miliseconds or 1/1000 of a second | |
// turn right eye off. LOW means set voltage to LOW. | |
digitalWrite(rEye, LOW); | |
delay (1000); //wait for 1 second. Delay is set in miliseconds or 1/1000 of a second | |
// turn left eye off. LOW means set voltage to LOW. | |
digitalWrite(lEye, LOW); | |
delay (1000); //wait for 1 second. Delay is set in miliseconds or 1/1000 of a second | |
// we are at end of loop - we go back to the beginning | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment