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: MODSERIAL QEI mbed
Revision 13:6cea4a9fcf7a, committed 2015-10-23
- Comitter:
- Technical_Muffin
- Date:
- Fri Oct 23 09:40:45 2015 +0000
- Parent:
- 12:2d3d7a9ca496
- Child:
- 14:41d069cf4701
- Commit message:
- pre-commit to save possible changes before revising the toggle function
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Oct 16 09:51:14 2015 +0000
+++ b/main.cpp Fri Oct 23 09:40:45 2015 +0000
@@ -34,8 +34,8 @@
led2.write(1);
pc.baud(115200);
- int diffa1 = button1.read();//read out the button 1 signal and calculate if it is being pressed or released
- wait(0.2);//from this we can determine if the rotation direction needs to be reversed.
+ int diffa1 = -button1.read();//read out the button 1 signal and calculate if it is being pressed or released interrupt function might work better as toggle
+ wait(0.3);//from this we can determine if the rotation direction needs to be reversed.
int diffb1 = button1.read();
int button_toggle1 = diffa1-diffb1;
if(button_toggle1 == 1 && motor1_dir == CW){
@@ -63,7 +63,7 @@
}
int diffa2 = button2.read();//read out the button 2 signal and calculate if it is being pressed or released
- wait(0.2);//from this we can determine if the rotation direction needs to be reversed.
+ wait(0.3);//from this we can determine if the rotation direction needs to be reversed.
int diffb2 = button2.read();
int button_toggle2 = diffa2-diffb2;
if(button_toggle2 == 1 && motor2_dir == CW){
@@ -80,7 +80,7 @@
led2.write(0);
while(n2 == 1){
speed2.write(cycle);//write speed only on first run through the loop
- direction2.write(1);//turn motor CCW or CW
+ direction2.write(motor2_dir);//turn motor CCW or CW
n2=0;
}