Hey guys, I'm having trouble with knowing what exactly my equation is doing. The sony remote that I am using with my arduino board and receiver uses a 38.5kHz signal. Only problem is interpreting it on c language.
What I did so far was store raw data values of when a signal was transmitted (HIGH and LOW values) then with the code below I tried converting it into 1s and 0s to make more sense of reading the raw data. What happens when I make numFromPort = 0 is that when I press "1" on the Sony remote it returns 0 which it should since all raw data values are LOW in this case. It is when I press any other button besides "1" it returns the interpreted signal one number off from what it was supposed to be. So if I made numFromPort = 1, it will read "1" as 1 and the rest will be fine but I do not understand why. If I left numFromPort = 0, and I press "2" it returns a value 999999 instead of 1000000. I have numFromPort as an unsigned integer. Any help on the equation or coding would be great. Thanks
Thanks, that's an awesome library. Here's another rookie question but how would I read three separate readings and store that into an array for later? I set up another array so that it can label the IR signal '1' as 1, '2' as 2, etc. I want to enter in a 3+ digit number, store it and then accumulate it as one large number at the end. For example I enter in 1, 2 and 3 on the Sony remote, I want the array to store those three numbers, then accumulate them together so the program recognizes it as integer 123. How would I start that off?
It sounds complicated.
I guess use 'if statements'
if (input == sony 2){
x=2 * 100
}
and for the next one:
if (x>0){
if (input == sony 2){
y= 2 * 10
FinalNumber= x + y
}
}
And have a timer setup so that timer=millis() and a variable like now=millis() is always updating.
It will expire after something like 6 seconds, now-timer > 6000. At the end of the time then x,y,and z go back to 0
I figured it out. I should have tried the millis(). I did one with increments of int k++ and that seemed to work as it would add one everytime through the loop and only when it receives a signal that way it can compile the three separate numerical inputs into one number.
I ended up with something that looked like this:
if (counter % 2 == 1){
if (label >= 0 && label <= 9 && k<3){
Angle[k] = label;
Serial.print(label);
k++;
delay(350);
}
//do whatever is needed here once k == to a certain value
}
That way only three iterations were allowed, the rest would not be printed or placed into an array. Much help would be appreciated if someone knows a more efficient way of doing it. Mine seems to work but to me, seems crude.