Different application with Capsense button

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

  Hi,

   

I want to get information for an application.I pushed capsense button, for example works motor. If I press the even longer same button works another motor. For example counter. When I pressed button for once, increase counter once, ı hold down same capsense button counter increase in tens. How should I do this with program. Thanks.

0 Likes
2 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Basically you implement a time counter or a clock connected to an ISR. To

   

differentiate how long you hold a button down, and based on time held

   

implement different functions, like starting the alternate motor.

   

 

   

So create a timer, say 100 mS, enable its interrupt, and each time ISR

   

fires inc a time counter. Then in main() test the counter and based on its

   

value action different tasks. When released you clear the time counter.

   

 

   

Regards, Dana.

   

 

   

0 Likes
Anonymous
Not applicable

For controlling motors :--

   

 

   

You can use a timer for this.

   

 

   

As a button press is detected, start the timer . And as the button is released, stop the timer.

   

Read the timer value.

   

If it is more than a threshold value [selected by you, say 2 seconds] then motor2 is started. Else motor1 is started.

   

 

   

Regards.

0 Likes