Hi,
I have an infrared sensor and a Vizio TV remote. Does anyone know of a simple (the simpler the better) code that will print the value of the infrared sensor to a variable. I had the sensor hooked up to an Analog input using the basic sample code and all that was being printed was "0" when I clicked a button and "1023" when I did not press a button, so I know for sure that the sensor works. Thanks.
How much time did you spend searching? Less than a minute would be my guess. IR Remote yielded 978 results on the Arduino forum alone. Surely one of those 978 links would have taken you to Ken Shirriff's excellent library.
Does anyone know of a simple (the simpler the better) code that will print the value of the infrared sensor to a variable.
Print the value to a variable? What does that mean?
Well I have been fiddling with the code below, but i keep getting the error message " 'IRrecv' does not name a type". If you could explain the issue it would be greatly appreciated.
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
Is that the first error message? Do you have the IRremote library? Pay attention to capitalization.
It is the first error message and I have the infrared library. any ideas?
Which IDE version are you using?
1.0
I downloaded the library, followed the advice on Ken's website relating to changes required for IDE 1.0, and your sketch compiled first time.
I will have to try it again.