control for robotic arm that can play chess using a granular gripper
Dependencies: Encoder mbed HIDScope Servo MODSERIAL
Fork of chessRobot by
Diff: buttons.cpp
- Revision:
- 34:f315b2b38555
- Parent:
- 32:2006977785f5
- Child:
- 35:e26a573e3e9f
diff -r 0baaf98c717d -r f315b2b38555 buttons.cpp --- a/buttons.cpp Wed Oct 07 18:56:52 2015 +0000 +++ b/buttons.cpp Wed Oct 07 19:04:09 2015 +0000 @@ -21,6 +21,9 @@ int prevState2 = 0; int actuatorState = 0; +float pot1Val = 0; +float pot2Val = 0; + void checkSwitches(){ @@ -29,10 +32,13 @@ // button 2 to switch between states if(button1 !=0 && prevState1 == 0){ - button1Pressed(); + motorsEnable = !motorsEnable; } if(button2 !=0 && prevState2 ==0){ - button2Pressed(); + actuatorState++; + if(actuatorState==3){ + actuatorState = 0; + } } prevState1 = button1; prevState2 = button2; @@ -44,7 +50,7 @@ switch (actuatorState){ case 0: // potmeters control X speed led1 = 1; led2=0; - motorSetSPeed1 = 300*(pot2.read()-pot1.read()); + motorSetSpeed1 = 300*(pot2.read()-pot1.read()); break; case 1: // potmeters control Y speed led1=0; led2=1; @@ -59,17 +65,4 @@ led1=0; led2=0; } motorSetSpeed2 = motorSetSpeed2 - 300*pot1.read(); - } - - -void button1Pressed(){ - motorEnable = !motorEnable; -} - -void button2Pressed(){ - actuatorState++; - if(actuatorState=3){ - actuatorState = 0; - } - -} \ No newline at end of file + } \ No newline at end of file