Created
April 19, 2014 00:31
-
-
Save dag10/11069601 to your computer and use it in GitHub Desktop.
Cylon Eye 595
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
const int pin_data = 2; | |
const int pin_clock = 3; | |
const int pin_latch = 4; | |
byte cylon = 0b10000000; | |
boolean right = true; | |
void output(byte data) { | |
digitalWrite(pin_latch, LOW); | |
shiftOut(pin_data, pin_clock, MSBFIRST, data); | |
digitalWrite(pin_latch, HIGH); | |
} | |
void setup() { | |
pinMode(pin_data, OUTPUT); | |
pinMode(pin_clock, OUTPUT); | |
pinMode(pin_latch, OUTPUT); | |
digitalWrite(pin_latch, LOW); | |
} | |
void loop() { | |
if (right) { | |
cylon >>= 1; | |
if (cylon == 0b00000001) { | |
right = false; | |
} | |
} else { | |
cylon <<= 1; | |
if (cylon == 0b10000000) { | |
right = true; | |
} | |
} | |
output(cylon); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment