Author Topic: Make LED's display the binary equivalent of an ASCII value.  (Read 6330 times)

Agradon

  • Guest
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

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Make LED's display the binary equivalent of an ASCII value.
« Reply #1 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.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS