Ranbeer Singh
Full Member level 5
- Joined
- Jul 30, 2015
- Messages
- 259
- Helped
- 22
- Reputation
- 44
- Reaction score
- 22
- Trophy points
- 1,298
- Location
- Faridabad India
- Activity points
- 3,266
Hello,
I am implementing a function for add or subtract variable value according to button pressed time.
When i press button for a short time it should increase or decrease 0.1 from variable. When i press button for 4-5 second, it should increase or decrease 1 from variable. When i press button more then 8 second, it should increase or decrease every time 10 from variable.
My concern is, how can i set X in 0.1, 1, 10 format according to button pressed time?
I am implementing a function for add or subtract variable value according to button pressed time.
When i press button for a short time it should increase or decrease 0.1 from variable. When i press button for 4-5 second, it should increase or decrease 1 from variable. When i press button more then 8 second, it should increase or decrease every time 10 from variable.
Code:
float x = 0.01
while(a < 200)
{
if(DownKey)
{
k -= x;
a = 0;
}
if(UpKey)
{
k += x;
a = 0;
}
if(k > 99.99) k = 99.99;
if(k < 0) k = 0;
delay_10ms();
a++;
}
My concern is, how can i set X in 0.1, 1, 10 format according to button pressed time?
Last edited: