// 20DF8877 1 button on remote // 20DFC837 3 button on remote #include //Look this up online to get this line of code working int outPin = 4; int outPin2 = 3; int state = LOW; int state2 = LOW;// 0 = LED off while 1 = LED on int RECEIVE_PIN = 6; IRrecv irrecv(RECEIVE_PIN); decode_results results; //button ints int previous = LOW; int previous2 = LOW; long time = 0; long debounce = 200; void setup() { Serial.begin(9600); irrecv.enableIRIn(); pinMode(outPin, OUTPUT); pinMode(outPin2, OUTPUT); //button setup pinMode(2, INPUT); pinMode(5, INPUT); } void loop() { if ((irrecv.decode(&results)) && (results.value== 0x20DF8877) ) { if (state == HIGH) { state = LOW; digitalWrite(outPin, LOW); Serial.println("Center - HIGH"); } else { state = HIGH; digitalWrite(outPin, HIGH); } delay(500); irrecv.resume(); } //222222 if ((irrecv.decode(&results)) && (results.value== 0x20DFC837) ) { if (state2 == HIGH) { state2 = LOW; digitalWrite(outPin2, LOW); Serial.println("Center - HIGH"); } else { state2 = HIGH; digitalWrite(outPin2, HIGH); } delay(500); irrecv.resume(); } if (irrecv.decode(&results)){ irrecv.resume(); } //button loop int sensorVal = digitalRead(5); int sensorVal2 = digitalRead(2); //print out the value of the pushbutton // if the input just went from LOW and HIGH and we've waited long enough // to ignore any noise on the circuit, toggle the output pin and remember // the time if (sensorVal == LOW && previous == HIGH && millis() - time > debounce) { if (state == HIGH) state = LOW; else state = HIGH; time = millis(); } digitalWrite(outPin, state); previous = sensorVal; //22222 //print out the value of the pushbutton // if the input just went from LOW and HIGH and we've waited long enough // to ignore any noise on the circuit, toggle the output pin and remember // the time if (sensorVal2 == LOW && previous2 == HIGH && millis() - time > debounce) { if (state2 == HIGH) state2 = LOW; else state2 = HIGH; time = millis(); } digitalWrite(outPin2, state2); previous2 = sensorVal2; }