Pushbutton slew control with acceleration

RonTon

New member
I have been looking through the forums for code to use two buttons to slew a word variable up and down. I want it to slew faster if the button is held down. Can anyone help with this?

Thanks,
Ron
 

premelec

Senior Member
Welcome to this forum - an approach could be using a variable which is incremented or decremented depending on which button is pressed and that variable is involved in the timing... or if you need two different rates for which way you are going then use two variables... Decrement a timing variable each time you sample the input buttons and reset it when no input button detected - what have you got so far?
 

RonTon

New member
I am new to this so don't have much yet. I want it to step by one count each time the up or down button is pressed but if the button is held down for say 3 seconds the count would go faster the longer the button is held up to a maximum of 50 counts per second. When the button is released it would go back to one count per short press.
 
Top