Skip to content

Instantly share code, notes, and snippets.

@dag10
Created April 19, 2014 00:31
Show Gist options
  • Save dag10/11069601 to your computer and use it in GitHub Desktop.
Save dag10/11069601 to your computer and use it in GitHub Desktop.
Cylon Eye 595
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