press+hold with Milli help [SOLVED]
i trying add second push button+hold can't seem rite !
the first press works, second push+hold 800ms works , when comes third push+hold 1500ms goes through second , starts third action.
the second pulse(continousweld) has break command exists loop , when existing starts third action also.
here intent do
first press , release 1 action
press+hold 800ms starts continousweld
press+hold 2000 starts action.
the first press works, second push+hold 800ms works , when comes third push+hold 1500ms goes through second , starts third action.
the second pulse(continousweld) has break command exists loop , when existing starts third action also.
here intent do
first press , release 1 action
press+hold 800ms starts continousweld
press+hold 2000 starts action.
code: [select]
void loop()
{
while (!zerocrossingflag) //as zc error detect, set ready light on when 0 cross detected else off.
{
digitalwrite(rdy, low);
}
digitalwrite(rdy, high);
// start debug
if (oldweldstepvalue != weldstep())
{
weldstepval();
oldweldstepvalue = weldstep();
}
//end debug
pulsesetled();
//myservo.write(srvstartset());
//myservo.write(srvendset());
btnstate = digitalread(btn);
if (btnstate == low && buttonlast == high && (millis() - btnuptime) > long(debounce)) // test button pressed , store down time
{
btndntime = millis();
}
if (btnstate == high && buttonlast == low && (millis() - btndntime) > long(debounce)) // test button release , store time
{
if (ignoreup == false) weld(100, 400);
else ignoreup = false;
btnuptime = millis();
}
if (btnstate == low && (millis() - btndntime) > long(holdtime)) // check hold time
{
continousweld();
ignoreup = true;
btnuptime = millis();
}
if (btnstate == low && (millis() - btndntime) > long(holdtime2)) // test button held down longer hold time
{
setweldhead();
ignoreup = false;
btndntime = millis();
}
buttonlast = btnstate;
zerocrossingflag = false;
}
please post code next time. see http://snippets-r-us.com/
problem is, 2000ms long press work correct can check if 800ms pressed happened when button released.
problem is, 2000ms long press work correct can check if 800ms pressed happened when button released.
Arduino Forum > Using Arduino > Project Guidance > press+hold with Milli help [SOLVED]
arduino
Comments
Post a Comment