Replies: 1 comment 3 replies
-
Is the SimpleReceiver Example working??? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is the SimpleReceiver Example working??? |
Beta Was this translation helpful? Give feedback.
-
Hi, I am having trouble with the IRremote library. Whether it's on the uno or the nano, the code works for about 2 button presses then stops responding to input. When I try to isolate the problem and test a program that just prints the hexadecimal numbers for each button in the serial monitor, it works smoothly for all buttons, but anything more complicated than that, like a RGB light or a DC motor fan, and it just stops working a few presses in. I contacted Arduino support and after sending verbose output messages they concluded that the problem is the library and not the IDE. Any idea why?
Circuit:
https://www.tinkercad.com/things/lqr7MdKRwil-copy-of-stunning-elzing/editel?sharecode=D2YLsVpsTh8iinyyUWR0Gl43dABPNnW2aUJz-SnyZUM
Code:
#include <IRremote.h>
int recPin = 11; //receiver pin
int d = 250;
int pin1 = 6;
int pin2 = 5;
int pin3 = 3;
int bval = 1;
int b1;
int b2;
int b3;
float bv1;
float bv2;
float bv3;
void setup() {
Serial.begin(9600);
IrReceiver.begin(recPin, ENABLE_LED_FEEDBACK); //enabling the receiver
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(A2,INPUT);
pinMode(pin1,OUTPUT);
pinMode(pin2,OUTPUT);
pinMode(pin3,OUTPUT);
}
void loop() {
if(IrReceiver.decode()){
Serial.print(IrReceiver.decodedIRData.decodedRawData, HEX);
Serial.print(" ");
if (IrReceiver.decodedIRData.decodedRawData == 0xBA45FF00){ //if power is pressed
if(bval == 0){
bval = 1;
analogWrite(pin1,bv1);
analogWrite(pin2,bv2);
analogWrite(pin3,bv3);
}
else{
bval = 0;
b1 = analogRead(A0);
b2 = analogRead(A1);
b3 = analogRead(A2);
bv1 = (255./1023.)*b1;
bv2 = (255./1023.)*b2;
bv3 = (255./1023.)*b3;
analogWrite(pin1,0);
analogWrite(pin2,0);
analogWrite(pin3,0);
}
}
if (IrReceiver.decodedIRData.decodedRawData == 0xE916FF00){ //zero
analogWrite(pin1,255);
analogWrite(pin2,255);
analogWrite(pin3,255);
Serial.println("White");
}
if(IrReceiver.decodedIRData.decodedRawData == 0xF30CFF00){
analogWrite(pin1,0);
analogWrite(pin2,255);
analogWrite(pin3,255);
Serial.println("aqua");
}
if(IrReceiver.decodedIRData.decodedRawData == 0xE718FF00){
analogWrite(pin1,128);
analogWrite(pin2,0);
analogWrite(pin3,128);
Serial.println("purple");
}
if(IrReceiver.decodedIRData.decodedRawData == 0xA15EFF00){
analogWrite(pin1,255);
analogWrite(pin2,255);
analogWrite(pin3,0);
Serial.println("yellow");
}
if(IrReceiver.decodedIRData.decodedRawData == 0xF708FF00){
analogWrite(pin1,255);
analogWrite(pin2,140);
analogWrite(pin3,0);
Serial.println("orange");
}
if(IrReceiver.decodedIRData.decodedRawData == 0xE31CFF00){
analogWrite(pin1,255);
analogWrite(pin2,20);
analogWrite(pin3,147);
Serial.println("pink");
}
if(IrReceiver.decodedIRData.decodedRawData == 0xA55AFF00){
analogWrite(pin1,0);
analogWrite(pin2,128);
analogWrite(pin3,128);
Serial.println("teal");
}
if(IrReceiver.decodedIRData.decodedRawData == 0xBD42FF00){
analogWrite(pin1,139);
analogWrite(pin2,69);
analogWrite(pin3,19);
Serial.println("brown");
}
if(IrReceiver.decodedIRData.decodedRawData == 0xAD52FF00){
analogWrite(pin1,112);
analogWrite(pin2,128);
analogWrite(pin3,144);
Serial.println("gray");
}
delay(250);
IrReceiver.resume(); //start reading again
}
}
Beta Was this translation helpful? Give feedback.
All reactions