I'd like to do the following:
Button is pressed and held down
Motor starts at 50% for 5s, then jumps to 100%
Motor remains at 100% as long as button is held
Button is released, motor stops
Button is pressed again, motor starts again at 50% for 5s
I know I'll need a timer and probably a counter (or use maths?), but not sure how to tie them together.
Something like
if button = true then start timer
if timer <=5 then counter = 0, else counter = 1
if counter = 0 then output PWM = 50, else output PWM = 100
??
Hi, You would set it up something like this. Use a generic function as so - the value of the generic function will be 0 when the output has been on for less than 5s, and 1 when the output has been on for more than 5s.
Then in your output configuration, you can map the PWM to the state of the generic function as so.
You will just need to set your output function to on if button state equals true.