Starting and stopping a cog with a push button
Alright, so I've read over the Methods and Cogs chapter in PE Kit Labs but I can't seem to find a solid sample code to work with to make what i want to happen. basically, can someone give me a basic sample code for having a cog run, then when you push a button/flip a switch, the cog disables until the switch is let go of again.
I just can't seem to be able to use cogstop() properly. sorry about the grammar, i'm typing on my phone. thanks for taking a look.
I just can't seem to be able to use cogstop() properly. sorry about the grammar, i'm typing on my phone. thanks for taking a look.

Comments
To pause until a switch changes state, you'd want to use WAITPEQ or WAITPNE. Look up the explanations in the Propeller Manual.
CON LED = 16 'pin numbers button = 0 VAR long stack[20] PUB ATest : run | cog repeat if ina[button]==0 and run==0 'if not button and not running run := 1 'start blink cog cog := cognew(Blink,@stack) delay(50) 'debounce elseif ina[button]==1 and run==1 'if button and running run := 0 'stop blink cog cogstop(cog) delay(50) 'debounce PRI Blink 'cog routine dira[LED] := 1 repeat !outa[LED] 'blink a LED delay(250) PUB delay(ms) waitcnt(clkfreq/1000*ms + cnt)Andy
Thanks everyone, but specifically Andy for the example. I can definately build what I need out of this.
CON _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 clock = 80_000_000 ms1 = clock / 1000 Led1 = 16 'pin assignments led2 = 23 button = 0 VAR long stack[10] PUB ATest | state state := 0 ' Initial state for normally open button ' state := 1 ' initial state for normally closed button repeat case ina[button] 0: if state==0 ' if in run state 0 cogstop(6) ' Stop running cog coginit(2,Blink(Led1),@stack) ' Start Blink in cog A state:=1 ' indicate run state 1 1: if state==1 ' if in run state 1 cogstop(2) ' Stop Blink in running cog coginit(6,Blink(Led2),@stack) ' Start Blink in cog B state := 0 ' indicate state 0 delay(50) ' for switch debounce PRI Blink(Pin) ' cog routine dira[Pin]~~ repeat !outa[Pin] ' blink a LED delay(250) PUB delay(ms) waitcnt(clkfreq/1000*ms + cnt)