Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 3:1f77b5e4eb42, committed 2015-10-29
- Comitter:
- yohoo15
- Date:
- Thu Oct 29 14:39:37 2015 +0000
- Parent:
- 2:90a9ed488f08
- Commit message:
- with begin of vader jacob
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 90a9ed488f08 -r 1f77b5e4eb42 main.cpp
--- 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);
+ }
}
}