SINGLE BUTTON IR REMOTE

single push button IR

#include <IRremote.h>
int RECV_PIN = 3;
const int ledPin1 = 6;
const int ledPin2 = 7;
const int ledPin3 = 8;
IRrecv irrecv(RECV_PIN);
decode_results results;
int buttonPushCounter = 0;
void setup()
{
Serial.begin(9600);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
irrecv.enableIRIn(); // Start the receiver
}
unsigned long last = millis();
void loop() {

if (irrecv.decode(&results)) {

if (results.value == 0xEF1001FE) { //code from your IR remote
if (millis() – last > 150) {
buttonPushCounter++;
Serial.println(“on”);
Serial.print(“number of button pushes: “);
Serial.println(buttonPushCounter);
}
last = millis();
}
irrecv.resume(); // Receive the next value
}
if (buttonPushCounter % 4 == 0) {
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);

}
if (buttonPushCounter % 4 == 1) {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
}
if (buttonPushCounter % 4 == 2) {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, LOW);
}
if (buttonPushCounter % 4 == 3) {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
}

}

/*

for double remote button for increase and decrease, see :

https://arduinoproyek.wordpress.com/double-button-ir-remote/

*/