Convert ASCII numbers to binary.

Paul Lamar

New Member
Has anybody written the code to
convert a four digit ASCII number to
a binary value? 8 bits? 16 bits?
Maybe 10 bits?

I am trying to design an auto pilot and
the ASCII heading data is coming in from a NEMA 0183 GPS receiver serial port.

Paul Lamar
 

BeanieBots

Moderator
The ASCII value is the numeric value plus $30.
So simply reverse it.
eg 3 digit number ABC
value=(A-$30)*100+(B-$30)*10+(C-$30)*1
 

hippy

Ex-Staff (retired)
And optimised, for 4-digit ABCD ...

w0 = A*10+B*10+C*10+D-53328

http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=5048
 
Top