Skip to content

Instantly share code, notes, and snippets.

@sledge-1
Created February 7, 2017 21:28
Show Gist options
  • Save sledge-1/31ca9f3e8adbe13e828579db660b6abf to your computer and use it in GitHub Desktop.
Save sledge-1/31ca9f3e8adbe13e828579db660b6abf to your computer and use it in GitHub Desktop.
void changeWhite(){
int threshold = analogRead(1);
if (threshhold > 819){
digitalWrite(4,HIGH);
}
else if (threshhold > 615){
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
}
else if (threshhold > 411){
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
}
else if (threshhold > 207){
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
}
else{
digitalWrite(newThreshold,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
}
}
void changeColors(){
int threshold = analogRead(1);
int newThreshold = (-threshold) + 1023;
if (analogRead(3) < 333){
analogWrite(9,newThreshold);
}
else if (analogRead(3) < 666){
analogWrite(10,newThreshold);
}
else{
analogWrite(11,newThreshold);
}
}
void setup()
{
pinMode(1, INPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(3,INPUT);
Serial.begin(9600);
}
void loop()
{
changeWhite();
changeColors();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment