Turning a number into "beeps"
I'm building an altimeter (for a rocket), and my current system of using an LCD to display the ADCout takes up too much power. Instead, I simply want to use a beeper to report the number. For example, 4392 would be:
beep-beep-beep-beep-long beep--beep-beep-beep-long beep--beep-beep-beep-beep-beep-beep-beep-beep-beep-long beep-beep-beep-
10 is represented by 10 normal beeps.
Is there a quick and simple algorithm to do this (I'm using the BS1)? Thanks!
EDIT: I figured most of it out, but I still have this question:
If you divide, say 3024, by 1000 (3024/1000), is the answer 3 or 3.024?
However, I'm simply using this as something to count up to in a loop, so does it even matter?
Thanks!
Post Edited (ghost13) : 6/7/2007 12:41:13 AM GMT
beep-beep-beep-beep-long beep--beep-beep-beep-long beep--beep-beep-beep-beep-beep-beep-beep-beep-beep-long beep-beep-beep-
10 is represented by 10 normal beeps.
Is there a quick and simple algorithm to do this (I'm using the BS1)? Thanks!
EDIT: I figured most of it out, but I still have this question:
If you divide, say 3024, by 1000 (3024/1000), is the answer 3 or 3.024?
However, I'm simply using this as something to count up to in a loop, so does it even matter?
Thanks!
Post Edited (ghost13) : 6/7/2007 12:41:13 AM GMT
Comments
If you search search.parallax.com, you'll find more on the subject.
but I don't know if it is for BS1 though
The answer would be 3. The Stamp is integer math only. Check the Basic Stamp manual for info about the ** and */ operators which will let you do "fractions".
If you want beeps as you describe, easiest way would probably be to extract your numerical values first, e.g.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
Post Edited (Zoot) : 6/7/2007 2:11:56 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
4321 would blink all leds on and off to signal the start then the 4th, third, second and 1st. I understand the rocket is probably in the sunlight but i think LEDs should be bright enough. I think trying to count all those beeps might get a bit tedious and I think LEDS would also be lower power as well overall.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
My number is only four digits, though. How do I alter the code?
Should it be the following?
[/code][/size]
Thanks!
Post Edited (ghost13) : 6/7/2007 5:36:46 AM GMT
ioByte = myNumber/1000 'get 1000s
GOSUB Play_Number
ioByte = myNumber//1000/100 'get 100s
GOSUB Play_Number
ioByte = myNumber//100/10 'get 10s
GOSUB Play_Number
ioByte = myNumber//10 'get 1s
GOSUB Play_Number
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST