Newbie in coding

I am trying to code a robot arm, and on the end of the arm i have a servo motor with a arm attachment. But i want it to open when i press a button, and then close when i press the button again.
Now i just use:
if (z == 0){
arm.write(120);
}
if (z == 1){
arm.write(0);
}

You need to detect when the button becomes pressed rather than when it is pressed

See the StateChangeDetection example in the IDE

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.