Graphic LEDs to display Binary?
Author |
Message |
mapleleaf31
|
Posted: Wed Jan 19, 2005 4:32 pm Post subject: Graphic LEDs to display Binary? |
|
|
Ok so I'm making a program where I need to convert any character to ASCII and then to Binary and to display both of them, I have that written.
The second part of it is too have 8 circles that are "LED"'s on the screen and have them fill to represent the Binary number, I can't figure out how to do the LED part
SO far my code is...
code: | var letter : string
drawoval (50, 350, 20, 20, 2)
drawoval (100, 350, 20, 20, 2)
drawoval (150, 350, 20, 20, 2)
drawoval (200, 350, 20, 20, 2)
drawoval (250, 350, 20, 20, 2)
drawoval (300, 350, 20, 20, 2)
drawoval (350, 350, 20, 20, 2)
drawoval (400, 350, 20, 20, 2)
locatexy (50, 110)
put "Enter the letter"
get letter
put ord (letter)
put intstr (ord (letter), 0, 2)
|
Can anyone help me? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Drakain Zeil
|
Posted: Wed Jan 19, 2005 6:04 pm Post subject: (No subject) |
|
|
First you need to know how binary works...
1 - 1
2 - 10
3 - 11
4 - 100
5 - 101
6 - 110
7 - 111
8 - 1000
9 - 1001
10 - 1010
11 - 1011
12 - 1100
13 - 1101
14 - 1110
15 - 1111
...
I wrote somthing about it in my blong awhile back, if you want that I can find the link to the specific post,
When I was younger I had a book on how to build one (hardware, out of some chips and whatnot), I could try and find that and post it up, doubt it would help with software however. Google might have somthing simmilar...
Anyway, find out how binary works, that's first.
Next, find out what the ascii letters are, how they work...
Third, find out how to convert between decimal and binary.
Once you have these, get the character, then use ord(character), convert this number to binary (actually, I think there's somthing in turring that does this for you, stringint or somthing like that), then depending on the location of each 1, turn on that light. |
|
|
|
|
![](images/spacer.gif) |
mapleleaf31
|
Posted: Wed Jan 19, 2005 7:21 pm Post subject: (No subject) |
|
|
I know how binary works and I got how to convert it in the code up there, the thing I can't figure out is how to get Turing to recognize the new binary number and fill in the circles |
|
|
|
|
![](images/spacer.gif) |
Neo
![](http://compsci.ca/v3/uploads/user_avatars/441131374462fea7633fd3.gif)
|
Posted: Wed Jan 19, 2005 7:55 pm Post subject: (No subject) |
|
|
You'd want to use a for loop, each time you want to find the remainder, use mod 2, and store the value in a variable. If the remaind is 1 then fill in a circle. Then divide the number by 2. Repeat... |
|
|
|
|
![](images/spacer.gif) |
|
|