converting string data to a numeric value
Dgswaner
Posts: 795
I'm trying to receive a value from 0-255, convert it to a number between 500-2300 and then use that value to drive the servos.
I know the communication is working, but what I believe to be happening is that it's reading X as a string and not a numeric value, I can't find anything in the manual to convert this to the value. I've used something like VAL(X) in other languages.
the 0-255 is being generated by a HTML page (pink) and needs to be a integer. Here is my code.
Is there a way around this? any help would be appreciated.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
I know the communication is working, but what I believe to be happening is that it's reading X as a string and not a numeric value, I can't find anything in the manual to convert this to the value. I've used something like VAL(X) in other languages.
the 0-255 is being generated by a HTML page (pink) and needs to be a integer. Here is my code.
PUB Main repeat x := XB.RX ' receives a byte of data comm.dec(x) 'sends byte to pc SERVO.Set(TiltServo,(X * 7) + 500) '500 - 2300 SERVO.Set(PanServo,(X * 7) + 500) ' 500 - 2300 waitcnt (cnt+140_000)
Is there a way around this? any help would be appreciated.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
http://obex.parallax.com/objects/230/
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
jazzed·... about·living in·http://en.wikipedia.org/wiki/Silicon_Valley
Traffic is slow at times, but Parallax orders·always get here fast 8)