566Views9Replies
Arduino IR remote to set a value
Hello, I'm new here
I'm using an Arduino UNO with a VS1838B IR receiver and a remote control, I can receive signals perfectly and decode them, but I want like if I press a button, it's value goes to a variable, example: if I press "button 5" then an "OK button" a variable A=0 become A=5.
Thanks
Comments
4 years ago
There are several ways to do this. One would be the switch/case statement, it's pretty straight-forward.
4 years ago
Thanks for support, I tried another methode, my project is actually temperature control, I have 2 actions cooling and heating, I acquire the ambient temperature and compare it to another constants, I want that the user select the temperature he wants, I think I will try to set the "A" with a value then modifying it with plus or minus button.
Thanks
Reply 4 years ago
See, with more info it is easier to get support, you should have included that in the initial question and maybe still a bit more ;)
If it is just about temperature control you might want to look into a dedicated controll like the REX100 and clones.
They only cost around 30 bucks and have the buttons, set functions and control already included.
As for coding you might want to simplify your approach.
Use some display code and variables to show up.
Add support for up and down button or an encoder knob while keeping the code working.
Now start adding the routines for temp control just as an independent block to work with fixed values - still keep the rest of the code working.
After all this replace the fixed values with your variables and it should work as expected.
Not sure where you got the idea of hex code but simple inputs and push buttons work just fine for this.
Reply 4 years ago
Actually, my project was to set the temperature in the arduino and then control the relays, but now we must let the user chose his own temperature interval or value.
I looked for the REX100, but our project must be based on Arduino and it's modules only.
It's okay now I've set the minimum value to a value1, and the maximum value to a value2, the user can modify them by incrementing or decrementing with a remote control then he press okay then the system start comparing the temperature from a sensor and start heating or cooling.
Thanks I'm new in this domain started working with arduino a month ago.
Reply 4 years ago
Then you might want to check the simulator 123D offers ;)
Get your circuit on the breadboard, connect to the Arduino and run your code.
Using the virtual world is sometimes easier than editing, uploading, rewiring...
Once it works in the simulator you simply transfer it to your real project ;)
Reply 4 years ago
Very useful,I had some wiring problems too ^^, but it works.
Thank you.
4 years ago
You need to understand and learn basic Arduino coding first before you modify programs.
IMHO you best bet is to start with the example sketches and to focus and working with variables and how to store/manipulate them.
Messing with code without knowing what you are actually doing usually only causes a lot of frustration...
4 years ago
Read through and you should be able to adapt the sample code in there to assign values to variables specific to your setup. Good luck.
https://learn.adafruit.com/using-an-infrared-libra...
4 years ago
Update:
I used this (( #define CH1 0x264C7D03 )) Button name(CH1, 1, 2 ....) and it's HEX code, and I could use them.
I will update if I get some other results