Reading Array values into variables
This is probably easy, but I can't seem to figure it out.
I have an array of 34 bytes collected via Serin2. I can see each of these. What I need to do tho is read several of them and convert them from the hex values they represent now to decimal.
So imagine:
SSMAX(23) contains 83
SSMAX(34) contains 03
These make up a temperature measurement.
I need to reverse these so I get 03 83, then convert these to DECIMAL
03 83 to Decimal should give me 899. There is an implied decimal between the 9's so I'd divide by 10. the result would be 89.9
BUT.. I can't find a way to get the data out of the array to deal with it.
Does anyone have any ideas about this?
I was planning to read each character 0 - 3 - 8 - 3 in sequence via a loop and multiply the 0*4096+3*256+8*16+3*1... But I can't seem to get data ouf of the array..
I can't seem to get the array values into variables to work on them either.
Thanks - this is new stuff for me.
Tom
Thanks for the quick replies! Question about the math
The 4th post includes this:
SSD4= (ssmax[34]>>4)
SSD3= (ssmax[34] & $f)
SSD2= (ssmax[23]>>4)
SSD1= (ssmax[23] & $f)
It appears that somehow this is reading the digits out of the bytes, but I have never seen the notation before.
>>
& $f
Do these somehow mean first digit and second digit?
TG
Array values into Variables - into ONE variable..
Seems like I should be able to figure this out, but I can't ...
I have an array that contains 24 bits which equate to an altitude in tenths of meters.
alt[1]
alt[2]
alt[3]
I need to 1) display this, and 2) convert from meters to feet, so I need to stuff all these into a single variable which represents actual meters as opposed to tenths of meters, then convert to feet....
Any ideas out there? They way I am doing it now is not working. I am just reading these into alt1, alt2, alt2, and showing them as #alt1, #alt2, #alt3... I get 13130 which may be 131.30 meters,(which would be about right) but I am not sure. I am also not sure how to make this a single variable ..
Thanks !
Tom