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: Servo mbed Motor
Revision 9:8682923e9260, committed 2014-11-03
- Comitter:
- tsevcik08
- Date:
- Mon Nov 03 01:39:08 2014 +0000
- Parent:
- 8:30eb49981a91
- Commit message:
- final commented
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 23 00:05:07 2014 +0000
+++ b/main.cpp Mon Nov 03 01:39:08 2014 +0000
@@ -30,56 +30,56 @@
w = 16;
while(1) {
- if( sw4 == 1 && sw5 == 0 && sw1 == 0 && sw2 == 0 ) {
+ if( sw4 == 1 && sw5 == 0 && sw1 == 0 && sw2 == 0 ) {//while switch four is on
mspeed = 0.40;
kate.speed(mspeed);
- wait(.05);
+ wait(.05);//structure move for .05 seconds
mspeed = 0.0;
kate.speed(mspeed);
- wait(.25);
+ wait(.25);//structure stop for .25 seconds
if(w < 1 || w > 16){
w=16; }
w = w/2; //moves LED to the right by changing binary value
- } else if( sw5 == 1 && sw4 == 0 && sw1 == 0 && sw2 == 0) {
+ } else if( sw5 == 1 && sw4 == 0 && sw1 == 0 && sw2 == 0) {//while switch five is on
mspeed = -0.40;
kate.speed(mspeed);
- wait(.05);
+ wait(.05);//structure moves in reverse for .05 seconds
mspeed = 0.0;
kate.speed(mspeed);
- wait(.25);
+ wait(.25);//structure stops moving for .25 seconds
if(w < 1 || w > 16){
w=1;
}
- w = w*2;
- } else if (sw3 == 1 && sw2 == 0 && sw1 == 0 && sw4 == 0 && sw5 == 0 ) {
- for (servopos = 0; servopos <= 0.5; servopos += 0.5) {
+ w = w*2;//move LED to the left by changing the binary value
+ } else if (sw3 == 1 && sw2 == 0 && sw1 == 0 && sw4 == 0 && sw5 == 0 ) {//while switch three is on
+ for (servopos = 0; servopos <= 0.5; servopos += 0.5) {//closes the claw
scoop = servopos;
- w = 8;
+ w = 8; // LED three is on
}
wait (1);
- } else if(sw1 == 1 && sw2 == 0 && sw5 == 0 && sw4 == 0 ) {
+ } else if(sw1 == 1 && sw2 == 0 && sw5 == 0 && sw4 == 0 ) {//while switch one is on
armpos += .02;
- arm = armpos;
+ arm = armpos;//arm position moves up by .02
wait(.05);
w=31;
- wait(.05);
+ wait(.05);//lights flicker between on and off
w= 0;
- } else if(sw2 == 1 && sw1 == 0 && sw4 == 0 && sw5 == 0) {
+ } else if(sw2 == 1 && sw1 == 0 && sw4 == 0 && sw5 == 0) {//while stich two is on
armpos -= .08;
- arm = armpos;
+ arm = armpos;//arm position moves down by .08
wait(.05);
w=3;
- wait(.25);
+ wait(.25);//lights flicker between LED 1 and 2 on and LED 3, 4, and 5 on
w=28;
- } else if (sw4 == 0 && sw1 == 0 && sw2 == 0 && sw3 == 0 && sw5 == 0) {
- mspeed = 0.0;
+ } else if (sw4 == 0 && sw1 == 0 && sw2 == 0 && sw3 == 0 && sw5 == 0) {//while all switches off
+ mspeed = 0.0;// no movement of the structure
kate.speed(mspeed);
- arm = armpos;
+ arm = armpos;// arm stays in the position
wait(.1);
for (servopos = 1.0; servopos >= 0; servopos -=1.0) {
- scoop = servopos;
+ scoop = servopos;//claw opens up
}
}
}