Trouble understanding the "count" function.
brup
Posts: 14
I have a bs2. I have a program that blinks a led on and off. I need the led to blink 10 times and then end the program. Any ideas on how to do this? Do I use a count command? If so how do I do that?
Comments
The COUNT command is used to count INCOMING pulses.
I would use a FOR...NEXT loop
FOR temp = 1 TO 10
' Your blink code
NEXT
Of course you will have to declare the variable "temp".
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
·
For your particular needs, look at the FOR / NEXT statement chapters in the Stamp Basic Syntax and Reference Manual. You can download this from Parallax if you don't have it already. There are also examples in the "What's a Microcontroller?" tutorial also downloadable from Parallax.
Go to the main Parallax webpage and click on the Resources tab, then click on Downloads, then Stamps in Class Downloads.
To change how any times it blinks just change the 10 to whatever number of blinks you want. To change duration, change the pause duration. Hope this helps.
will sound.I have the program and the program for tone working but I cannot get it to step to the next relay
any ideas? I want to use the same sound for each relay. How do i get it to second relay after sound.
(next,return)?
relay 1
sound
relay 2
sound
relay 3
sound
relay 4
GOSUB relay1 'contains Relay ON, Time, Relay OFF code, ends with RETURN
GOSUB sound 'contains code for tone including nested sub, end with RETURN
PAUSE xxx 'optional pause before relay2
GOSUB relay2
GOSUB sound
PAUSE
GOSUB relay3 .....
a more efficient way would be to have one generic Relay subroutine to which you would pass parameters indicating which output you wish to control and how much time.
after 255 so it never reaches 900ms.
The pause function is limited but I think this for... next loop can just cycle what the pause function is capable of and achieve your desired pause. Hope this helps!