Controls the rovot with pot meters and button, fall back for if the filters fail
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:1f77b5e4eb42
- Parent:
- 2:90a9ed488f08
--- a/main.cpp Thu Oct 29 10:52:46 2015 +0000 +++ b/main.cpp Thu Oct 29 14:39:37 2015 +0000 @@ -13,6 +13,7 @@ //button to press the key DigitalIn button_key(PTC6); +DigitalIn button_song(PTA4); //pot meters to act as emg filter substitutes AnalogIn left_pot(A0); @@ -24,6 +25,7 @@ //int to check if the button is pressed const int Button_move_pressed = 0; +const int Button_song_pressed = 0; //values for clockwise and counter clockwise movement const int cw = 1; @@ -80,6 +82,160 @@ //more of a safety catch than actually necessary PWM_key.write(0); PWM.write(0); + + //cw to the right + if (button_song.read() == Button_song_pressed){ + + //pressing va + directionPin_key.write(cw); + PWM_key.write(1); + wait(0.14); //time it takes pwm of one to reach the key + //pause at the key for one second + PWM_key.write(0); + wait(1); + //move bakc to the starting position + directionPin_key.write(ccw); + PWM_key.write(1); + //time needs to be slightly longer than moving forward (no answer why) + wait(0.165f); + PWM_key.write(0); + + // go 1 key to right + directionPin.write(cw); + PWM.write(1); + wait(2.2); + PWM.write(0); + + //pressing der + directionPin_key.write(cw); + PWM_key.write(1); + wait(0.14); //time it takes pwm of one to reach the key + //pause at the key for one second + PWM_key.write(0); + wait(1); + //move bakc to the starting position + directionPin_key.write(ccw); + PWM_key.write(1); + //time needs to be slightly longer than moving forward (no answer why) + wait(0.165f); + PWM_key.write(0); + + // go 1 key to right + directionPin.write(cw); + PWM.write(1); + wait(2.2); + PWM.write(0); + + //pressing ja + directionPin_key.write(cw); + PWM_key.write(1); + wait(0.14); //time it takes pwm of one to reach the key + //pause at the key for one second + PWM_key.write(0); + wait(1); + //move bakc to the starting position + directionPin_key.write(ccw); + PWM_key.write(1); + //time needs to be slightly longer than moving forward (no answer why) + wait(0.165f); + PWM_key.write(0); + + // go 2 key to left + directionPin.write(ccw); + PWM.write(1); + wait(4.5); + PWM.write(0); + + //pressing cob + directionPin_key.write(cw); + PWM_key.write(1); + wait(0.14); //time it takes pwm of one to reach the key + //pause at the key for one second + PWM_key.write(0); + wait(1); + //move bakc to the starting position + directionPin_key.write(ccw); + PWM_key.write(1); + //time needs to be slightly longer than moving forward (no answer why) + wait(0.165f); + PWM_key.write(0); + + wait(1.5); + + //pressing va + directionPin_key.write(cw); + PWM_key.write(1); + wait(0.14); //time it takes pwm of one to reach the key + //pause at the key for one second + PWM_key.write(0); + wait(1); + //move bakc to the starting position + directionPin_key.write(ccw); + PWM_key.write(1); + //time needs to be slightly longer than moving forward (no answer why) + wait(0.165f); + PWM_key.write(0); + + // go 1 key to right + directionPin.write(cw); + PWM.write(1); + wait(2.2); + PWM.write(0); + + //pressing der + directionPin_key.write(cw); + PWM_key.write(1); + wait(0.14); //time it takes pwm of one to reach the key + //pause at the key for one second + PWM_key.write(0); + wait(1); + //move bakc to the starting position + directionPin_key.write(ccw); + PWM_key.write(1); + //time needs to be slightly longer than moving forward (no answer why) + wait(0.165f); + PWM_key.write(0); + + // go 1 key to right + directionPin.write(cw); + PWM.write(1); + wait(2.2); + PWM.write(0); + + //pressing ja + directionPin_key.write(cw); + PWM_key.write(1); + wait(0.14); //time it takes pwm of one to reach the key + //pause at the key for one second + PWM_key.write(0); + wait(1); + //move bakc to the starting position + directionPin_key.write(ccw); + PWM_key.write(1); + //time needs to be slightly longer than moving forward (no answer why) + wait(0.165f); + PWM_key.write(0); + + // go 2 key to left + directionPin.write(ccw); + PWM.write(1); + wait(4.5); + PWM.write(0); + + //pressing cob + directionPin_key.write(cw); + PWM_key.write(1); + wait(0.14); //time it takes pwm of one to reach the key + //pause at the key for one second + PWM_key.write(0); + wait(1); + //move bakc to the starting position + directionPin_key.write(ccw); + PWM_key.write(1); + //time needs to be slightly longer than moving forward (no answer why) + wait(0.165f); + PWM_key.write(0); + } } }