newbie needs simple help
hello all,
i'm working on a project for work that needs to flash an led 30 times in 10 seconds when a button is pressed. I convinced my boss that the propeller was the perfect thing for this. i'm just having some problems with the programming. the hardware i can manage. this is the code i have so far. it works the first time the button is pressed but thats it. I know it is a simple piece of code. can anyone please help me.
pub toggle
repeat
if ina[noparse][[/noparse] 0 ] ==1
dira[noparse][[/noparse]4..9]~~
repeat until outa[noparse][[/noparse]9..4]++ == 60
waitcnt(clkfreq/6 + cnt)
dira~
i'm working on a project for work that needs to flash an led 30 times in 10 seconds when a button is pressed. I convinced my boss that the propeller was the perfect thing for this. i'm just having some problems with the programming. the hardware i can manage. this is the code i have so far. it works the first time the button is pressed but thats it. I know it is a simple piece of code. can anyone please help me.
pub toggle
repeat
if ina[noparse][[/noparse] 0 ] ==1
dira[noparse][[/noparse]4..9]~~
repeat until outa[noparse][[/noparse]9..4]++ == 60
waitcnt(clkfreq/6 + cnt)
dira~

Comments
Have you read the tutorial and PE Kit Labs?· They come with the Propeller Tool.
dira[noparse][[/noparse]0]~ ' set as input dira[noparse][[/noparse]1]~~ ' set as output repeat repeat until ina[noparse][[/noparse] 0] == 1 ' wait for button repeat 60 ' flash led !outa[noparse][[/noparse]1] ' toggle LED pin waitcnt(clkfreq / 10 + cnt) ' wait a whileJohn Abshier
when you paste code into the forum, it's important to use the CODE tags so your indentation is preserved. Paste your code between
[noparse][[/noparse] code ]
and
[noparse][[/noparse] / code ]
except remove all the spaces I placed within the brackets.
That way your code looks like this