PC to PIC communication

RickAlty

Senior Member
Hello, I want to pass a five digit number from a PC to be displayed on a set of 5 7-segment LED's. I have got the driver chip wired to the LED's, and have the PICAXE succesfully displaying numbers on the LED. This code.... (Pin 3 is 'clock' and pin 4 is 'data' for the driver chip)

main:

high 3
pause 1
low 3
pause 1
high 4
high 3
pause 1
low 3
low 4
gosub six
gosub seven
gosub eight
gosub nine
gosub zero
high 3
pause 1
low 3



high 3
pause 1
low 3
pause 1
high 4
high 3
pause 1
low 3
low 4
gosub one
gosub two
gosub three
gosub four
gosub five
high 3
pause 1
low 3

goto main

shows "12345" and "67890" alternately, so I'm driving the driver correctly.

What I can't figure out succesfully is how to get, say, "11975" from the PC and then tell the PICAXE to GOSUB one, GOSUB one, GOSUB nine, GOSUB seven, GOSUB five so as to display the right number.

Can someone point me in the right direction?

Richard
 

Technical

Technical Support
Staff member
Along the lines of:

<code><pre><font size=2>
main:
serin 3,t2400,b1,b2,b3,b4,b5


let b0 = b1
gosub test
let b0 = b2
gosub test
let b0 = b3
gosub test
let b0 = b4
gosub test
let b0 = b5
gosub test
goto main


test:
if b0 = 1 then display1
if b0 = 2 then display2
if b0 = 3 then display3
if b0 = 4 then display4
if b0 = 5 then display5
return

display1:
gosub one
return

display2:
gosub two
return
</code></pre></font>
etc.

The only thing to watch is how you send the data from the computer - raw bytes or ASCII characters?


Edited by - Technical on 4/8/2005 5:23:07 PM
 

Toris

New Member
Hi,

Sorry to not answer your question (though hopefully Technical has already done that), but would it be possible for you to let me know what driver chip you are using?

Thanks,
Jamie.
 

RickAlty

Senior Member
Thanks, Technical. That would do it... I am right in that I can't do IF... THEN GOSUB in Picaxe basic, right?

I hadn't yet gotten to the point of looking at the VB code to send the data. What would be easiest? I was thinking of a string, as a couple of the variables might only be four digits sometimes, so I could send &quot;B1234&quot; as a string and have a sub &quot;Blank&quot; to display a leading blank digit rather than a zero.

Toris - I'm using M5451 chips. Each can drive 35 LED segments, so they're perfect for my 5-digit 7-sgment displays. (There's a DP too, but it's always on and always in the same place, so I can hardwire that.)

Richard
 
Top