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;
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
//decodes the infrared input
long int decCode = results.value;
//switch case to use the selected remote control button
case 16724175: /////////////////////////////// Toggle button system
case 16718055: /////////////////////////////// Toggle button system
case 16743045: ////////////////////////////// Push ON & Push OFF
bluePin = ~ bluePin;
irrecv.resume(); // Receives the next value from the button you press
}Toggle_Switch_Sketch.ino (1.5 KB)
Please use code tags.
What library are you using? What does your remote look like? Your code is a mess.
Clean up your post, and then I might be able to help you.
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.
You have two blue pins? Better to name this properly:
#define BluePin 4
int bluePinState = LOW;
Easier to understand, no?
I think he is presetting it to LOW before the code starts.
I used to do this. For some reason I thought that if you didn't define a pin state before
void loop(), it would be "undefined" and "act weird".
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.
For good reason - imagine what happens if a Release is missed due to weak signals.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.