# 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!

#### Nigel Goodwin

##### Super Moderator
German1981 said:
Thous = freq/1000
freq = freq - freq*1000

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

And the same for the other lines!.

#### German1981

##### New Member
Stamp

Ok wow thats what i have been doing all along. I feel like an idiot now. Thanks for your help.

Status
Not open for further replies.

Replies
15
Views
929
Replies
5
Views
9K
Replies
12
Views
1K
Replies
1
Views
1K
Replies
7
Views
1K