hello friends i need the digital 7 pin white led,IR remote control Button press "ON" button release "OFF" switching.how to edit the sketch
int IR_Recv = 3; //IR Receiver Pin 3 #define BluePin 4
int bluePin = LOW;
int greenPin = 5;
int yellowPin = 6;
int whitePin = 7;
IRrecv irrecv(IR_Recv);
decode_results results;
void setup(){
Serial.begin(9600); //starts serial communication
irrecv.enableIRIn(); // Starts the receiver
pinMode(BluePin, OUTPUT); // sets the digital pin as output
pinMode(greenPin, OUTPUT); // sets the digital pin as output
pinMode(yellowPin, OUTPUT); // sets the digital pin as output
pinMode(whitePin, OUTPUT); // sets the digital pin as output
}
void loop(){
//decodes the infrared input
if (irrecv.decode(&results)){
long int decCode = results.value;
Serial.println(results.value);
//switch case to use the selected remote control button
switch (results.value){
case 16724175: /////////////////////////////// Toggle button system
digitalWrite(greenPin, HIGH);
delay(250);
digitalWrite(greenPin, LOW);
break;
case 16718055: /////////////////////////////// Toggle button system
digitalWrite(yellowPin, HIGH);
delay(250);
digitalWrite(yellowPin, LOW);
break;
case 16743045: ////////////////////////////// Push ON & Push OFF
bluePin = ~ bluePin;
digitalWrite(BluePin,bluePin);
break;
}
irrecv.resume(); // Receives the next value from the button you press
Read the forum guidelines to see how to properly post code. You can edit your original post to include code tags. Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
What does the improperly posted code do? What is it supposed to do?
There is no way to know when the button on a remote is released with the IRremote library.
What version of the IRremote library are you using? The above code is written for an older version (<3.0) and may not work right with the newest version of the IRremote library.
Most IR Remote buttons don't signal both Press and Release. Some, like Volume Up and Volume Down, will either send the same message repeating as long as the button is pressed or send the button once and a 'Repeat' code as long as the button is pressed.
To detect a button release you have to use a button that sends repeated codes and use a timer to detect when the repeats have stopped.