I'm a b.tech student and i'm building my project using IRremote library,It's too good...But I'm facing problems in developing my program for security based IR remote. I want users to enter a 4 digit password using a normal remote, And if it's correct then only it will allow him/her to access other services. For that I want to save each password digit entered via My TV remote to Integers or any other data type values. But I don't know much about CLASS an STRUCTURE in arduino. How can I have these decoded values direct to my defined integers?? can anyone give me links or any suggestions??
Hi
While I've not used this library, reading the header the value returned (in results.value) is an unsigned long. So you wouldn't need a class or structure to get your proof of concept running but you will need to have a way of mapping these codes from your remote to the integers printed on the remote's buttons. BTW because there's no negatives in a PIN, you could use unsigned integers and save half your space to store them too.
If you want to make your code modular and re-usable, defining a class and having your data in a structure can make sense. Though in this case there's really not a lot of complexity to encapsulate so I'd suggest there's no need.
Your PIN could be stored in a data type as simple as an array of unsigned integers, length 4; and you could compare it against allowable PINs stored (say) on the Arduino EEPROM, or even just hard-coded. If you want to learn about classes and structures there's plenty of reading in any reference on C++ that translates nearly directly to Arduino. Cracking open some of the libraries (even the IRremote one) will give you plenty of examples to view too.
Cheers, Geoff
I have not attempted to to anything as complex as use an Arduino as a password system, however, I am assuming that you are using a 3-pin IR Sensor such as this one: RadioShack.com Official Site - America's Technology Store
Unit setup:
pin 1 = -output
pin 2 = ground
pin 3 = +5VDC
(Green for now) LED:
Anode: +5VDC
Cathode: to -output of IR Receiver via 100? resistor
(Without an Arduino, hooking the LED to the IR Receiver like this will at least let me see the IR Remote output with my naked eye.)
When hooking up the sensor, I hooked the -output to an analog input then did a analogRead as fast as it would go, then did a serialWrite also as fast as it would go then monitored it on my computer screen. One would assume that you could take the displayed values of the buttons pushed and write another code designed to look for those codes and respond accordingly using "if/else" statements. I was successful in reading the IR commands, although I am not total convinced that all the code was captured properly, but I cannot find my IR emitter to test an output of that code repeated from the Arduino sketch. I will make a trip to the electronics store to pick up a new one then update this post with my results.
Not sure if this was helpful :~, but I hope you got something out of it. Good Luck!
I suggest you use Ken's IR code hashing, see it explained here: Using arbitrary remotes with the Arduino IRremote library
and an example: http://files.arcfn.com/files/IRhashdecode.pde