JonRon
March 5, 2021, 7:23am
1
Hi,
Back in 2016 I was learning about Arduinos and I wrote a short program to sort of play "Smoke on the water" (Deep Purple) and dim an led when buttons on an old TV remote were pressed.
I got it to work fine then and it works fine now but only with versions of irRemote up to version 2.6.1, it doesn't work with 2.7.0 and later versions.
Something changed in the irRemote library which I can't spot.
Any suggestions much appreciated
Thanks
Ron
#include <IRremote.h>
#define irPin 11
IRrecv irrecv(irPin);
decode_results results;
const int ledPin = 5;
int brightness = 10;
const int buzzer = 3;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(ledPin, OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
switch (results.value) {
case 0x1000405:
if(brightness < 255) {brightness = brightness+5;}
analogWrite(ledPin, brightness);
Serial.println(brightness);
tone(buzzer, 1000); // Send 800Hz sound signal...
delay(50); // ...for 50ms
noTone(buzzer);
delay(250);
break;
case 0x1008485:
if(brightness > 0) {brightness = brightness-5;}
analogWrite(ledPin, brightness);
Serial.println(brightness);
tone(buzzer, 800); // Send 800Hz sound signal...
delay(50); // ...for 50ms
noTone(buzzer);
delay(250);
break;
case 0x100BCBD:
Serial.println("OFF");
analogWrite(ledPin, 0);
brightness = 20;
tone(buzzer, 784); // Send G5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 932); // Send Bb5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 1046); // Send C6 sound signal...
delay(800); // ...for 200ms
tone(buzzer, 784); // Send G5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 932); // Send Bb5 sound signal...
delay(500); // ...for 200ms
tone(buzzer, 1109); // Send Db6 sound signal...
delay(300); // ...for 200ms
tone(buzzer, 1046); // Send C6 sound signal...
delay(1200); // ...for 200ms
tone(buzzer, 784); // Send G5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 932); // Send Bb5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 1046); // Send C6 sound signal...
delay(800); // ...for 200ms
tone(buzzer, 932); // Send G5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 784); // Send G5 sound signal...
delay(150); // ...for 200ms
noTone(buzzer);
delay(100); // ...for 200ms
tone(buzzer, 784); // Send G5 sound signal...
delay(1600); // ...for 200ms
noTone(buzzer);
break;
}
irrecv.resume();
}
}
6v6gt
March 5, 2021, 8:28am
2
Don't open new threads for essentially the same issue.
https://forum.arduino.cc/index.php?topic=730467.0
The forum is littered enough with recent IRremote library change related problems.
edit
Have you read the readme.md here: GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols ?
Try a simple example from the library there, then apply any important changes to your own code.
JonRon
March 5, 2021, 10:07am
3
It's good to see that there are like minded folk with an interest in using the irRemote library and are keen to see that the problems encountered with it are resolved.
Let's hope that the knowledgeable members of this forum who know the answers are willing to help out by answering the questions posed by those keen to learn.
The IRremote library has been updated. The APIs have changed. All the information for using the new version is right in the README at the GitHub site: GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols
6v6gt
March 5, 2021, 1:48pm
5
This appears to work with a clean 3.0.3 version of the IRremote library.
You seem to have ignored the modification the @johnwasser mentioned in your previous thread.
However, you have to change the line marked <<<<<<<<<<<<<<<<<<<<<< when it becomes clear what code your remote is delivering. It appears to me that, at some time, the code order may have been inverted.
/*
* Specify which protocol(s) should be used for decoding.
* If no protocol is defined, all protocols are active.
*/
//#define DECODE_NEC 1
#define IR_USE_TIMER1 // this was missing
#include <IRremote.h>
const int IR_RECEIVE_PIN = 11 ;
const int ledPin = 5;
int brightness = 10;
const int buzzer = 3;
void setup() {
Serial.begin(9600);
IrReceiver.begin( IR_RECEIVE_PIN , DISABLE_LED_FEEDBACK);
pinMode(ledPin, OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
if (IrReceiver.decode() ) {
switch ( IrReceiver.decodedIRData.decodedRawData ) { // results.value
case 0x1000405:
if (brightness < 255) {
brightness = brightness + 5;
}
analogWrite(ledPin, brightness);
Serial.println(brightness);
tone(buzzer, 1000); // Send 800Hz sound signal...
delay(50); // ...for 50ms
noTone(buzzer);
delay(250);
break;
case 0x1008485:
if (brightness > 0) {
brightness = brightness - 5;
}
analogWrite(ledPin, brightness);
Serial.println(brightness);
tone(buzzer, 800); // Send 800Hz sound signal...
delay(50); // ...for 50ms
noTone(buzzer);
delay(250);
break;
case 0x100BCBD:
default: /// <<<<<<<<<<<<<<<<<<<<<<<<<<<
Serial.println("OFF");
analogWrite(ledPin, 0);
brightness = 20;
tone(buzzer, 784); // Send G5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 932); // Send Bb5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 1046); // Send C6 sound signal...
delay(800); // ...for 200ms
tone(buzzer, 784); // Send G5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 932); // Send Bb5 sound signal...
delay(500); // ...for 200ms
tone(buzzer, 1109); // Send Db6 sound signal...
delay(300); // ...for 200ms
tone(buzzer, 1046); // Send C6 sound signal...
delay(1200); // ...for 200ms
tone(buzzer, 784); // Send G5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 932); // Send Bb5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 1046); // Send C6 sound signal...
delay(800); // ...for 200ms
tone(buzzer, 932); // Send G5 sound signal...
delay(600); // ...for 200ms
tone(buzzer, 784); // Send G5 sound signal...
delay(150); // ...for 200ms
noTone(buzzer);
delay(100); // ...for 200ms
tone(buzzer, 784); // Send G5 sound signal...
delay(1600); // ...for 200ms
noTone(buzzer);
break;
}
Serial.println("====") ;
Serial.println(IrReceiver.decodedIRData.decodedRawData , HEX);
IrReceiver.printIRResultShort(&Serial);
//IrReceiver.printIRResultRawFormatted(&Serial, true);
Serial.println("-------") ;
IrReceiver.resume();
}
}
system
Closed
July 3, 2021, 1:48pm
6
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.