Created
September 20, 2015 02:47
-
-
Save tnoborio/9cd6a78efa900ef5351a to your computer and use it in GitHub Desktop.
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
const int a = 11; | |
const int b = 7; | |
const int c = 4; | |
const int d = 2; | |
const int e = 1; | |
const int f = 10; | |
const int g = 5; | |
const int p = 3; | |
const int d1 = 12; | |
const int d2 = 9; | |
const int d3 = 8; | |
const int d4 = 6; | |
const boolean isAnode = true; | |
void setup() { | |
for (int i = 1; i <= 12; i = i + 1) { | |
pinMode(i, OUTPUT); | |
} | |
} | |
void on(int pin) { | |
if (isAnode) { | |
digitalWrite(pin, HIGH); | |
} else { | |
digitalWrite(pin, LOW); | |
} | |
} | |
void off(int pin) { | |
if (isAnode) { | |
digitalWrite(pin, LOW); | |
} else { | |
digitalWrite(pin, HIGH); | |
} | |
} | |
void reset(int digiPin) { | |
off(d1); | |
off(d2); | |
off(d3); | |
off(d4); | |
on(digiPin); | |
on(a); | |
on(b); | |
on(c); | |
on(d); | |
on(e); | |
on(f); | |
on(g); | |
on(p); | |
} | |
void loop() { | |
reset(d1); | |
off(a); | |
delay(4); | |
reset(d2); | |
off(b); | |
delay(4); | |
reset(d3); | |
off(c); | |
delay(4); | |
reset(d4); | |
off(d); | |
delay(4); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment