Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
unsigned long csSum;
int looptype = 0;
int touchPad = 4;
int red = 0; //IO1 pin 7
int green = 1; //IO3 pin 2
int blue = 2; //IO3 pin 2
int state = HIGH;
int r;
int p = HIGH;
int time = 0;
int debounce = 100;
void setup()
{
pinMode(touchPad, INPUT);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
digitalWrite(green, HIGH);
digitalWrite(red, HIGH);
digitalWrite(blue, HIGH);
}
void loop()
{
//8mhz
if (looptype == 0) { //blink red and green
digitalWrite(red, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
delay(20);
digitalWrite(green, HIGH);
digitalWrite(red, HIGH);
digitalWrite(blue, HIGH);
delay(20);
} else if (looptype == 1) { //hyperflash both
digitalWrite(red, LOW);
delay(20);
digitalWrite(red, HIGH);
delay(20);
digitalWrite(green, LOW);
delay(20);
digitalWrite(green, HIGH);
delay(20);
digitalWrite(blue, LOW);
delay(20);
digitalWrite(blue, HIGH);
delay(20);
} else if (looptype == 2) { //blink Green
digitalWrite(red, HIGH);
digitalWrite(green, HIGH);
delay(50);
digitalWrite(green, LOW);
delay(50);
} else if (looptype == 3) { //slow flash both
digitalWrite(red, HIGH);
delay(50);
digitalWrite(red, LOW);
delay(50);
} else if (looptype == 4) { //slow flash both
digitalWrite(blue, HIGH);
delay(50);
digitalWrite(blue, LOW);
delay(50);
} else if (looptype == 5){
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);
digitalWrite(red, LOW);
}else if (looptype == 6){
digitalWrite(red, HIGH);
digitalWrite(blue, HIGH);
digitalWrite(green, LOW);
} else if (looptype == 7){
digitalWrite(red, HIGH);
digitalWrite(green, HIGH);
digitalWrite(blue, LOW);
}
r = digitalRead(touchPad);
if(r == HIGH && p == LOW && (time - millis()) >= debounce){
// digitalWrite(red, LOW);
if (looptype <= 7)
looptype = looptype + 1;
else
looptype = 0;
time = millis();
delay(10);
}
p = r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment