Created
November 25, 2016 03:36
-
-
Save fuho/0c457ea5a4b16e9c3de593914126e912 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
int pdip1 = 0, | |
pdip2 = 1, | |
pdip3 = 2, | |
pfet1 = 3, | |
pfet2 = 4; | |
bool conf0, conf1, conf2, fet1, fet2; | |
byte conf = 0; | |
byte getDipConfig(){ | |
conf0 = 1 & !digitalRead(pdip1); | |
conf1 = 1 & !digitalRead(pdip2); | |
conf2 = 1 & !digitalRead(pdip3); | |
return (conf0 << 2) | (conf1 << 1) | conf2; | |
} | |
void on(byte pin){ | |
digitalWrite(pin, HIGH); | |
} | |
void off(byte pin){ | |
digitalWrite(pin, LOW); | |
} | |
void effectDefault(){ | |
on(pfet1); | |
delay(500); | |
on(pfet2); | |
delay(500); | |
off(pfet1); | |
off(pfet2); | |
delay(500); | |
} | |
void effectDefaultReverse(){ | |
on(pfet2); | |
delay(500); | |
on(pfet1); | |
delay(500); | |
off(pfet1); | |
off(pfet2); | |
delay(500); | |
} | |
void effectDefaultFast(){ | |
on(pfet1); | |
delay(250); | |
on(pfet2); | |
delay(250); | |
off(pfet1); | |
off(pfet2); | |
delay(300); | |
} | |
void effectSnake(){ | |
on(pfet1); | |
delay(200); | |
on(pfet2); | |
delay(200); | |
off(pfet1); | |
delay(200); | |
off(pfet2); | |
delay(200); | |
} | |
void effectKnight(){ | |
on(pfet1); | |
delay(200); | |
on(pfet2); | |
delay(200); | |
off(pfet1); | |
delay(200); | |
off(pfet2); | |
delay(250); | |
on(pfet2); | |
delay(200); | |
on(pfet1); | |
delay(200); | |
off(pfet2); | |
delay(200); | |
off(pfet1); | |
delay(250); | |
} | |
void effectDoubles(){ | |
on(pfet1); | |
delay(100); | |
off(pfet1); | |
delay(150); | |
on(pfet1); | |
delay(100); | |
off(pfet1); | |
delay(150); | |
on(pfet2); | |
delay(100); | |
off(pfet2); | |
delay(150); | |
on(pfet2); | |
delay(100); | |
off(pfet2); | |
delay(150); | |
} | |
void effectGradient(){ | |
} | |
void setup() { | |
pinMode(pdip1, INPUT_PULLUP); | |
pinMode(pdip2, INPUT_PULLUP); | |
pinMode(pdip3, INPUT_PULLUP); | |
pinMode(pfet1, OUTPUT); | |
pinMode(pfet2, OUTPUT); | |
} | |
void loop() { | |
conf = getDipConfig(); | |
switch(conf){ | |
case 0: | |
effectDefault(); | |
break; | |
case 1: | |
effectDefaultReverse(); | |
break; | |
case 2: | |
effectDefaultFast(); | |
break; | |
case 3: | |
effectSnake(); | |
break; | |
case 4: | |
effectKnight(); | |
break; | |
case 5: | |
effectDoubles(); | |
break; | |
case 6: | |
case 7: | |
effectDefault(); | |
; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment