outputting BCD values on a basic stamp

Status
Not open for further replies.

German1981

New Member
Hi, I am building a frequency counter and I want to output this value in BCD form on the pins of a BS2. Here is a bit of the code.

freq var word ' variable
Thous var byte
Hunds var byte
Tens var byte
Ones var byte

freq = 2345 ' just an example to test the program

Thous = freq/1000
freq = freq - freq*1000

Hunds = freq/100
freq = freq - freq*100

Tens = freq/10
freq = freq-freq/10

Ones = freq

When I write this code, the only number i am getting returned correctly to me is the Thousands digit. If anyone has any ideas, it would certainly be a great help!
 
German1981 said:
Thous = freq/1000
freq = freq - freq*1000

Shouldn't this line read:

Code:
Thous  = freq/1000
freq = freq - Thous*1000

And the same for the other lines!.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…