Conversion Commands
BuStOsAvIcH
Posts: 1
Hello, I am currently working on my senior design project with some colleagues and we have hit a stopping point in regards to programming. We need to convert from ASCII to decimal do a math formula and then convert from decimal back to ASCII in order to output it to our LCD screen. We're using the Super Carrier Board and obviously PBASIC.
We've spent the past few days trying to find this out so any help would be very helpful. Thanks.
Edit: The information is coming from an ultrasonic sensor (Maxbotix LV-MaxSonar-EZ1 Sonar Range Finder). We need to take the ASCII code, which is going to be a distance in inches, convert it to a decimal, do an equation to get the distance in feet and then convert that back to ASCII so we can display it on our LCD (Parallax 2x16 Serial LCD (Backlit)).
Post Edited (BuStOsAvIcH) : 7/24/2008 3:35:51 PM GMT
We've spent the past few days trying to find this out so any help would be very helpful. Thanks.
Edit: The information is coming from an ultrasonic sensor (Maxbotix LV-MaxSonar-EZ1 Sonar Range Finder). We need to take the ASCII code, which is going to be a distance in inches, convert it to a decimal, do an equation to get the distance in feet and then convert that back to ASCII so we can display it on our LCD (Parallax 2x16 Serial LCD (Backlit)).
Post Edited (BuStOsAvIcH) : 7/24/2008 3:35:51 PM GMT
Comments
If your data comes in through SERIN, then the format modifiers like DEC are the way to transform ascii on the fly into a number suitable for math operations. On the other hand, if you have a string like "12345" in memory, a subroutine like the following will convert it to a plain number:
Of course, the exact form depends on the details of where the ascii data is coming from.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com