Internet PLC Forum

General => Technical support => Topic started by: Agradon on July 19, 2004, 10:25:54 AM

Title: Make LED's display the binary equivalent of an ASCII value.
Post by: Agradon on July 19, 2004, 10:25:54 AM
Is there any way, using TBASIC to display the binary equivalent of an ASCII value? Say I input the number 2, I want the LED's to light up in the pattern representing 2's Hex equvalent ($32) in binary: 0011 0010. The way I have it set up now is a tedious procedure of checking (in TBASIC logic) what number 0-9 is being passed in, and then manually lighting up the LED's. For my project, I need to process large numbers and display their BCD equivalents on the output LED's, performing this manually isn't really an option.

-Gene
Title: Re:Make LED's display the binary equivalent of an ASCII value.
Post by: support on July 19, 2004, 09:49:14 PM
It is really easy with TBASIC!

Say if A$ contains a decimal or hexadecimal string (00 to FF) of an ascii number, then:

    OUTPUT[1] = VAL(A$)   ' if A$ contains decimal form of the number
    OUTPUT[1] = HEXVAL(A$) ' if A$ contains hexadecimal form.