hi, i am doing an IR project and couldnt turn the decode_resuts type into an integer type for managing and using it easily, can anyone help me?
my library is this one: https://github.com/z3t0/Arduino-IRremote
infrared_testing.ino (1.86 KB)
hi, i am doing an IR project and couldnt turn the decode_resuts type into an integer type for managing and using it easily, can anyone help me?
my library is this one: https://github.com/z3t0/Arduino-IRremote
infrared_testing.ino (1.86 KB)
People are not going to open a raw file here. Read the posts at the top of this Forum, especially on how to use code tags when posting source code.
this is my code
#include <IRremote.h>
#define led 10
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
int brightness;
void setup() {
Serial.begin(9600);
Serial.println("Enabling IRin");
irrecv.enableIRIn(); // Start the receiver
Serial.println("Enabled IRin");
pinMode (led, OUTPUT);
}
void loop() {
if(irrecv.decode(&results)){
switch (results.value){
case 0x941:
digitalWrite (led, HIGH);
brightness = 250;
break;
case 0x141:
digitalWrite (led, HIGH);
brightness = 250;
break;
case 0x942:
digitalWrite (led, LOW);
brightness = 0;
break;
case 0x142:
digitalWrite (led, LOW);
brightness = 0;
break;
//160 ++
case 0x160:
digitalWrite (led, LOW);
brightness = brightness + 10;
if (brightness > 250){
brightness = 250;
analogWrite (led, brightness);
delay (100);
}
analogWrite (led, brightness);
break;
case 0x960:
digitalWrite (led, LOW);
brightness = brightness + 10;
if (brightness > 250){
brightness = 250;
analogWrite (led, brightness);
delay (100);
}
analogWrite (led, brightness);
break;
//161
case 0x161:
if(brightness > 0){
brightness = brightness -10;
analogWrite(led, brightness);
if (brightness < 0){
brightness = 0;
break;
}
delay (100);
break;
}
case 0x961:
if(brightness > 0){
brightness = brightness -10;
analogWrite(led, brightness);
if (brightness < 0){
brightness = 0;
break;
}
delay (100);
break;
}
}
Serial.println(results.value, HEX);
delay (100);
irrecv.resume();
}
}
results.value is an integer. What is the real problem?
Thank you very much, i did not know it was an integer and tried to asign the results value by itself to an integer.