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 6:206fff3b20b0, committed 2015-10-09
- Comitter:
- Technical_Muffin
- Date:
- Fri Oct 09 09:33:24 2015 +0000
- Parent:
- 5:a1376ab695f3
- Child:
- 7:46d9f01afba2
- Commit message:
- start of toggle/movement combination
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Oct 07 18:33:16 2015 +0000
+++ b/main.cpp Fri Oct 09 09:33:24 2015 +0000
@@ -28,13 +28,27 @@
while(button1.read() != motor1_on){// turn on motor 1 when the button is being pressed
led3.write(1);
led1.write(0);
- pc.printf("%f", speed1.read());
+ speed1.write(cycle);//write the speed to the motor
+ speed1.period_us(100);//Set period of PWM to 100 us.
+ pc.printf("%f",speed1.read());//klopt nog niet, maar voorlopig zorgt het uitlezen ervoor dat het werkt.
direction1.write(motor1_dir);//turn motor CCW or CW
//motor CW = 0
//motor CCW = 1
- speed1.period_us(100);//Set period of PWM to 100 us.
- speed1.write(cycle);//write the speed to the motor
-}
+ }
+ pc.printf("toggle on or off %d \n ", button1.read());
+ int diffa = button1.read();
+ wait(0.2);
+ int diffb = button1.read();
+ int button_toggle = diffa-diffb;
+ if(button_toggle == 1 && led1.read() ==1){
+ led1.write(0);
+ led2.write(1);
+ }
+ else if(button_toggle == 1 && led2.read() == 1){
+ led1.write(1);
+ led2.write(0);
+ }
+
}
}
//determine speed of movement from the encoder signal