Last active
October 6, 2015 00:28
-
-
Save slambert/2903980 to your computer and use it in GitHub Desktop.
Custom Light Controller program for Arduino and relays
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
//relay pins | |
#define relayAPin 2 | |
#define relayBPin 3 | |
#define relayCPin 4 | |
#define relayDPin 5 | |
#define relayEPin 6 | |
#define relayFPin 7 | |
#define relayGPin 8 | |
#define relayHPin 9 | |
//pot pin | |
#define potPin A5 | |
//lowest change rate in milliseconds | |
#define lowRate 50 | |
//#define lowRate 125 | |
//highest change rate in milliseconds | |
#define highRate 2000 | |
// the length of your pattern (how many stages there are) | |
// Make sure this is consitant with number of BXXXX things in HGFEDCBA Pattern | |
#define patternLength 1280 | |
//timing | |
unsigned long previousMillis = 0; | |
unsigned long currentMillis = 0; | |
//flashing | |
static int currentPattern = 0; | |
//HGFEDCBA Patterns - FUN TO CHANGE!!! | |
//B"XXXX" for 4 channels | |
//B"XXXXXXXX" for 8 channels and so on | |
//Make sure to change the patten length above. | |
byte pattern[patternLength] = { | |
//count across med | |
B1111, B1111, B0111, B0111, B0011, B0011, B0001, B0001, | |
B0000, B0000, B1000, B1000, B1100, B1100, B1110, B1110, | |
B1111, B1111, B0111, B0111, B0011, B0011, B0001, B0001, | |
B0000, B0000, B1000, B1000, B1100, B1100, B1110, B1110, | |
B1111, B1111, B0111, B0111, B0011, B0011, B0001, B0001, | |
B0000, B0000, B1000, B1000, B1100, B1100, B1110, B1110, | |
B1111, B1111, B0111, B0111, B0011, B0011, B0001, B0001, | |
B0000, B0000, B1000, B1000, B1100, B1100, B1110, B1110, | |
//64 | |
// one moves across med | |
B1000, B1000, B0100, B0100, B0010, B0010, B0001, B0001, | |
B1000, B1000, B0100, B0100, B0010, B0010, B0001, B0001, | |
B1000, B1000, B0100, B0100, B0010, B0010, B0001, B0001, | |
B1000, B1000, B0100, B0100, B0010, B0010, B0001, B0001, | |
B1000, B1000, B0100, B0100, B0010, B0010, B0001, B0001, | |
B1000, B1000, B0100, B0100, B0010, B0010, B0001, B0001, | |
B1000, B1000, B0100, B0100, B0010, B0010, B0001, B0001, | |
B1000, B1000, B0100, B0100, B0010, B0010, B0001, B0001, | |
//128 | |
//one moves across fast | |
B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, | |
B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, | |
B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, | |
B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, | |
B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, | |
B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, | |
B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, | |
B1000, B0100, B0010, B0001, B1000, B0100, B0010, B0001, | |
//192 | |
//count across fast | |
B1111, B0111, B0011, B0001, B0000, B1000, B1100, B1110, | |
B1111, B0111, B0011, B0001, B0000, B1000, B1100, B1110, | |
B1111, B0111, B0011, B0001, B0000, B1000, B1100, B1110, | |
B1111, B0111, B0011, B0001, B0000, B1000, B1100, B1110, | |
B1111, B0111, B0011, B0001, B0000, B1000, B1100, B1110, | |
B1111, B0111, B0011, B0001, B0000, B1000, B1100, B1110, | |
B1111, B0111, B0011, B0001, B0000, B1000, B1100, B1110, | |
B1111, B0111, B0011, B0001, B0000, B1000, B1100, B1110, | |
//256 | |
//4 slow flash | |
B1111, B1111, B1111, B1111, B0000, B0000, B0000, B0000, | |
B1111, B1111, B1111, B1111, B0000, B0000, B0000, B0000, | |
B1111, B1111, B1111, B1111, B0000, B0000, B0000, B0000, | |
B1111, B1111, B1111, B1111, B0000, B0000, B0000, B0000, | |
B1111, B1111, B1111, B1111, B0000, B0000, B0000, B0000, | |
B1111, B1111, B1111, B1111, B0000, B0000, B0000, B0000, | |
B1111, B1111, B1111, B1111, B0000, B0000, B0000, B0000, | |
B1111, B1111, B1111, B1111, B0000, B0000, B0000, B0000, | |
// three moves across med | |
B1110, B1110, B0111, B0111, B1011, B1011, B1101, B1101, | |
B1110, B1110, B0111, B0111, B1011, B1011, B1101, B1101, | |
B1110, B1110, B0111, B0111, B1011, B1011, B1101, B1101, | |
B1110, B1110, B0111, B0111, B1011, B1011, B1101, B1101, | |
B1110, B1110, B0111, B0111, B1011, B1011, B1101, B1101, | |
B1110, B1110, B0111, B0111, B1011, B1011, B1101, B1101, | |
B1110, B1110, B0111, B0111, B1011, B1011, B1101, B1101, | |
B1110, B1110, B0111, B0111, B1011, B1011, B1101, B1101, | |
// winky winky flip flop med | |
B1100, B1100, B1111, B1111, B0011, B0011, B0000, B0000, | |
B1100, B1100, B1111, B1111, B0011, B0011, B0000, B0000, | |
B1100, B1100, B1111, B1111, B0011, B0011, B0000, B0000, | |
B1100, B1100, B1111, B1111, B0011, B0011, B0000, B0000, | |
B1100, B1100, B1111, B1111, B0011, B0011, B0000, B0000, | |
B1100, B1100, B1111, B1111, B0011, B0011, B0000, B0000, | |
B1100, B1100, B1111, B1111, B0011, B0011, B0000, B0000, | |
B1100, B1100, B1111, B1111, B0011, B0011, B0000, B0000, | |
// winky winky oney | |
B1111, B0111, B1111, B1011, B1111, B1101, B1111, B1110, | |
B1111, B0111, B1111, B1011, B1111, B1101, B1111, B1110, | |
B1111, B0111, B1111, B1011, B1111, B1101, B1111, B1110, | |
B1111, B0111, B1111, B1011, B1111, B1101, B1111, B1110, | |
B1111, B0111, B1111, B1011, B1111, B1101, B1111, B1110, | |
B1111, B0111, B1111, B1011, B1111, B1101, B1111, B1110, | |
B1111, B0111, B1111, B1011, B1111, B1101, B1111, B1110, | |
B1111, B0111, B1111, B1011, B1111, B1101, B1111, B1110, | |
//512 | |
// flash 2 | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000, | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000, | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000, | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000, | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000, | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000, | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000, | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000, | |
// bongos | |
B0100, B0010, B1000, B0001, B1000, B0010, B0100, B0001, | |
B0100, B0010, B1000, B0001, B1000, B0010, B0100, B0001, | |
B0100, B0010, B1000, B0001, B1000, B0010, B0100, B0001, | |
B0100, B0010, B1000, B0001, B1000, B0010, B0100, B0001, | |
B0100, B0010, B1000, B0001, B1000, B0010, B0100, B0001, | |
B0100, B0010, B1000, B0001, B1000, B0010, B0100, B0001, | |
B0100, B0010, B1000, B0001, B1000, B0010, B0100, B0001, | |
B0100, B0010, B1000, B0001, B1000, B0010, B0100, B0001, | |
//boom boom ta-ka ta-ka | |
B1111, B0000, B1111, B0000, B0111, B1110, B0111, B1110, | |
B1111, B0000, B1111, B0000, B1011, B1101, B1011, B1101, | |
B1111, B0000, B1111, B0000, B0111, B1110, B0111, B1110, | |
B1111, B0000, B1111, B0000, B1011, B1101, B1011, B1101, | |
B1111, B0000, B1111, B0000, B0111, B1110, B0111, B1110, | |
B1111, B0000, B1111, B0000, B1011, B1101, B1011, B1101, | |
B1111, B0000, B1111, B0000, B0111, B1110, B0111, B1110, | |
B1111, B0000, B1111, B0000, B1011, B1101, B1011, B1101, | |
//total random | |
B0100, B0010, B0001, B1000, B0010, B0100, B0001, B1000, | |
B0010, B0100, B1000, B0001, B0001, B1000, B0100, B0010, | |
B0100, B1000, B0010, B0001, B0001, B0010, B0100, B1000, | |
B0001, B1000, B0010, B0100, B0100, B0010, B1000, B0001, | |
B0100, B0010, B0001, B1000, B0010, B0100, B0001, B1000, | |
B0010, B0100, B1000, B0001, B0001, B1000, B0100, B0010, | |
B0100, B1000, B0010, B0001, B0001, B0010, B0100, B1000, | |
B0001, B1000, B0010, B0100, B0100, B0010, B1000, B0001, | |
//768 | |
//pyramid med | |
B1000, B1100, B1110, B1111, B1110, B1100, B1000, B0000, | |
B1000, B1100, B1110, B1111, B1110, B1100, B1000, B0000, | |
B1000, B1100, B1110, B1111, B1110, B1100, B1000, B0000, | |
B1000, B1100, B1110, B1111, B1110, B1100, B1000, B0000, | |
B1000, B1100, B1110, B1111, B1110, B1100, B1000, B0000, | |
B1000, B1100, B1110, B1111, B1110, B1100, B1000, B0000, | |
B1000, B1100, B1110, B1111, B1110, B1100, B1000, B0000, | |
B1000, B1100, B1110, B1111, B1110, B1100, B1000, B0000, | |
//reverse pyramid | |
B0001, B0011, B0111, B1111, B0111, B0011, B0001, B0000, | |
B0001, B0011, B0111, B1111, B0111, B0011, B0001, B0000, | |
B0001, B0011, B0111, B1111, B0111, B0011, B0001, B0000, | |
B0001, B0011, B0111, B1111, B0111, B0011, B0001, B0000, | |
B0001, B0011, B0111, B1111, B0111, B0011, B0001, B0000, | |
B0001, B0011, B0111, B1111, B0111, B0011, B0001, B0000, | |
B0001, B0011, B0111, B1111, B0111, B0011, B0001, B0000, | |
B0001, B0011, B0111, B1111, B0111, B0011, B0001, B0000, | |
//creepy crawly | |
B1100, B1010, B0110, B0101, B0011, B1010, B1001, B0101, | |
B1100, B1010, B0110, B0101, B0011, B1010, B1001, B0101, | |
B1100, B1010, B0110, B0101, B0011, B1010, B1001, B0101, | |
B1100, B1010, B0110, B0101, B0011, B1010, B1001, B0101, | |
B1100, B1010, B0110, B0101, B0011, B1010, B1001, B0101, | |
B1100, B1010, B0110, B0101, B0011, B1010, B1001, B0101, | |
B1100, B1010, B0110, B0101, B0011, B1010, B1001, B0101, | |
B1100, B1010, B0110, B0101, B0011, B1010, B1001, B0101, | |
//triangle staircase | |
B1000, B1100, B1110, B1111, B0001, B0010, B0100, B1000, | |
B1000, B0100, B0010, B0001, B1111, B1110, B1100, B1000, | |
B1000, B1100, B1110, B1111, B0001, B0010, B0100, B1000, | |
B1000, B0100, B0010, B0001, B1111, B1110, B1100, B1000, | |
B1000, B1100, B1110, B1111, B0001, B0010, B0100, B1000, | |
B1000, B0100, B0010, B0001, B1111, B1110, B1100, B1000, | |
B1000, B1100, B1110, B1111, B0001, B0010, B0100, B1000, | |
B1000, B0100, B0010, B0001, B1111, B1110, B1100, B1000, | |
//1024 | |
//flash up and down | |
B1000, B0000, B1100, B0000, B1110, B0000, B1111, B0000, | |
B1111, B0000, B0111, B0000, B0011, B0000, B1000, B0000, | |
B1000, B0000, B1100, B0000, B1110, B0000, B1111, B0000, | |
B1111, B0000, B0111, B0000, B0011, B0000, B1000, B0000, | |
B1000, B0000, B1100, B0000, B1110, B0000, B1111, B0000, | |
B1111, B0000, B0111, B0000, B0011, B0000, B1000, B0000, | |
B1000, B0000, B1100, B0000, B1110, B0000, B1111, B0000, | |
B1111, B0000, B0111, B0000, B0011, B0000, B1000, B0000, | |
//boom boom 1234 | |
B1111, B0000, B1111, B0000, B0111, B1011, B1101, B1110, | |
B1111, B0000, B1111, B0000, B1110, B1101, B1011, B0111, | |
B1111, B0000, B1111, B0000, B0111, B1011, B1101, B1110, | |
B1111, B0000, B1111, B0000, B1110, B1101, B1011, B0111, | |
B1111, B0000, B1111, B0000, B0111, B1011, B1101, B1110, | |
B1111, B0000, B1111, B0000, B1110, B1101, B1011, B0111, | |
B1111, B0000, B1111, B0000, B0111, B1011, B1101, B1110, | |
B1111, B0000, B1111, B0000, B1110, B1101, B1011, B0111, | |
//flash up | |
B1000, B0000, B1100, B0000, B1110, B0000, B1111, B0000, | |
B1111, B0000, B0111, B0000, B0011, B0000, B0001, B0000, | |
B1000, B0000, B1100, B0000, B1110, B0000, B1111, B0000, | |
B1111, B0000, B0111, B0000, B0011, B0000, B0001, B0000, | |
B1000, B0000, B1100, B0000, B1110, B0000, B1111, B0000, | |
B1111, B0000, B0111, B0000, B0011, B0000, B0001, B0000, | |
B1000, B0000, B1100, B0000, B1110, B0000, B1111, B0000, | |
B1111, B0000, B0111, B0000, B0011, B0000, B0001, B0000, | |
//flash up and flash | |
B1000, B0000, B1100, B0000, B1110, B0000, B1111, B0000, | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000, | |
B1111, B0000, B0111, B0000, B0011, B0000, B0001, B0000, | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000, | |
B1000, B0000, B1100, B0000, B1110, B0000, B1111, B0000, | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000, | |
B1111, B0000, B0111, B0000, B0011, B0000, B0001, B0000, | |
B1111, B1111, B0000, B0000, B1111, B1111, B0000, B0000 | |
//1280 | |
// <-leave comma off the last value | |
}; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(relayAPin, OUTPUT); | |
pinMode(relayBPin, OUTPUT); | |
pinMode(relayCPin, OUTPUT); | |
pinMode(relayDPin, OUTPUT); | |
pinMode(relayEPin, OUTPUT); | |
pinMode(relayFPin, OUTPUT); | |
pinMode(relayGPin, OUTPUT); | |
pinMode(relayHPin, OUTPUT); | |
Serial.println("Flash program, by Alexander Reben ArEbEn alex@areben.com"); | |
} | |
void loop(){ | |
currentMillis = millis(); | |
int potValue = analogRead(potPin); | |
int delayPot = map(potValue, 0, 1024, lowRate, highRate); | |
updateLightBlink(pattern, patternLength, delayPot); | |
} | |
void updateLightBlink (byte input[], int length, int interval){ | |
if(currentMillis - previousMillis > interval) { | |
digitalWrite(relayAPin, (input[currentPattern] & B00000001)); | |
digitalWrite(relayBPin, (input[currentPattern] & B00000010)); | |
digitalWrite(relayCPin, (input[currentPattern] & B00000100)); | |
digitalWrite(relayDPin, (input[currentPattern] & B00001000)); | |
digitalWrite(relayEPin, (input[currentPattern] & B00010000)); | |
digitalWrite(relayFPin, (input[currentPattern] & B00100000)); | |
digitalWrite(relayGPin, (input[currentPattern] & B01000000)); | |
digitalWrite(relayHPin, (input[currentPattern] & B10000000)); | |
if(currentPattern < length - 1) | |
{ | |
currentPattern++; | |
} | |
else | |
{ | |
currentPattern = 0; | |
} | |
previousMillis = currentMillis; | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment