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 WattBob_TextLCD globals
Diff: main.cpp
- Revision:
- 1:a91950a8e20f
- Parent:
- 0:d8528fbbaf9c
- Child:
- 2:ea2d1441d485
--- a/main.cpp Fri Nov 25 10:42:48 2011 +0000
+++ b/main.cpp Fri Nov 25 17:22:31 2011 +0000
@@ -20,8 +20,7 @@
#include "cmd_io.h"
#include "globals.h"
-#define MAINT_MODE "y" //add define to receive mode value
-#define SORT_MODE "z" //add define to receive mode value
+
//******************************************************************************
//declare ticker
@@ -216,6 +215,9 @@
case MAINT_MODE :
bSort_Mode = 0;
bMaint_Mode = 1;
+ servo_4.pulsewidth_us(0);
+ servo_0.pulsewidth_us(1000 + (0 * 1000) / 90);
+ servo_5.pulsewidth_us(1000 + (0 * 1000) / 90);
break;
@@ -243,11 +245,15 @@
sensor1.read();
if(sensor1 > 0.5) {
led1 = 1;
- valueLED1 = 1;
+ if((bSort_Mode == 1)&&(bMaint_Mode == 0)){
+ valueLED1 = 1;
+ }
}
else if(sensor1 < 0.5){
led1 = 0;
- valueLED1 = 0;
+ if((bSort_Mode == 1)&&(bMaint_Mode == 0)){
+ valueLED1 = 0;
+ }
}
}
@@ -267,7 +273,7 @@
//function for the state machine to move servos between 2 positions
void state_machine (){
-
+ if((bSort_Mode == 1)&&(bMaint_Mode == 0)){
switch(state)
{
case 0: // initial state
@@ -341,7 +347,8 @@
state = 0;
}
break;
- }
+ }
+ }
}
@@ -359,12 +366,12 @@
timer2p.attach(&sensor2p, 0.1); //function sensor2p is reading all the 0.1 ms
timer1p.attach(&sensor1p, 0.1); //function sensor1p is reading all the 0.1 ms
- if((bSort_Mode == 1)&&(bMaint_Mode == 0)){
+
counter1p.read();
counter2p.read();
timerstatemachine.attach(&state_machine, 0.1);
- }
+
clk = !clk;