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.
Revision 1:2ee833c4b76f, committed 2014-01-31
- Comitter:
- joliu
- Date:
- Fri Jan 31 22:08:20 2014 +0000
- Parent:
- 0:ae0fe1adad01
- Commit message:
- before sending to Amando. Unsure of revision status or functionality as is.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jun 25 01:09:35 2013 +0000
+++ b/main.cpp Fri Jan 31 22:08:20 2014 +0000
@@ -1,7 +1,48 @@
#include "mbed.h"
-Serial pc(USBTX, USBRX);
+//Serial pc(USBTX, USBRX);
Serial lcd(p28, p27);
+// V+/V- outputs cylinder down
+DigitalOut out1(p7);
+DigitalOut out2(p8);
+DigitalOut out3(p9);
+DigitalOut out4(p10);
+// V+/V- outputs cylinder up
+DigitalOut out5(p11);
+DigitalOut out6(p12);
+DigitalOut out7(p13);
+DigitalOut out8(p14);
+// Four push buttons left to right
+DigitalIn pushOne(p21);
+DigitalIn pushTwo(p22);
+DigitalIn pushThree(p23);
+DigitalIn pushFour(p24);
+// Run switch where p26 will be kept high
+// Can probably connect it to the 3.3V out
+DigitalIn runIn(p25);
+DigitalOut runOut(p26);
+
+float upTime;
+float downTime;
+float waitTime;
+unsigned int count = 0;
+typedef char * string;
+string strs[5] = {
+ "Up Time", // 0
+ "Down Time", // 1
+ "Wait Time", // 2
+ "Target Count", // 3
+ "Reset Counter" // 4
+};
+enum ValveMode {
+ UP,
+ DOWN
+};
+
+
+
+
+
void clearLCD()
{
lcd.printf("%c%c",0xFE,0x01);
@@ -34,71 +75,27 @@
-// V+/V- outputs cylinder down
-DigitalOut out1(p7);
-DigitalOut out2(p8);
-DigitalOut out3(p9);
-DigitalOut out4(p10);
-// V+/V- outputs cylinder up
-DigitalOut out5(p11);
-DigitalOut out6(p12);
-DigitalOut out7(p13);
-DigitalOut out8(p14);
-// Four push buttons left to right
-DigitalIn pushOne(p21);
-DigitalIn pushTwo(p22);
-DigitalIn pushThree(p23);
-DigitalIn pushFour(p24);
-// Run switch where p26 will be kept high
-DigitalIn runIn(p25);
-DigitalOut runOut(p26);
-
-typedef char * string;
-
-float upTime;
-float downTime;
-float waitTime;
-
-string strs[5] = {
- "Up Time", // 0
- "Down Time", // 1
- "Wait Time", // 2
- "Target Count", // 3
- "Reset Counter" // 4
-};
-
-
-enum ValveMode
+void setValve(ValveMode dir, int val)
{
- CLOSED,
- UP,
- DOWN,
- BOTH
-};
-
-unsigned int count = 0;
-
-void setValve(ValveMode dir)
-{
- switch(dir)
- {
- case CLOSED:
- //p0 = 0;
- //p1 = 0;
- //p2 = 0;
- //p3 = 0;
+ switch(dir) {
+ case DOWN:
+ out1 = val;
+ out2 = val;
+ out3 = val;
+ out4 = val;
break;
case UP:
- //p0 = 0;
- //p1 = 0;
- //p2 = 0;
- //p3 = 0;
+ out5 = val;
+ out6 = val;
+ out7 = val;
+ out8 = val;
break;
+
}
}
-void lcdShowParameters(int delay, int cycles)
+/*void lcdShowParameters(int delay, int cycles)
{
clearLCD();
setLCDpos(1,1);
@@ -128,8 +125,16 @@
lcd.printf("Y/N?");
}
}
+*/
-
+void printCount (int count)
+{
+ clearLCD();
+ setLCDpos(1,1);
+ lcd.printf("CURRENT COUNT IS");
+ setLCDpos(2,1);
+ lcd.printf("%d",count);
+}
int main()
@@ -240,33 +245,18 @@
upTime = times[0];
downTime = times[1];
waitTime = times[2];
- count++;
- out5 = 1;
- out6 = 1;
- out7 = 1;
- out8 = 1;
+
+ setValve(UP, 1);
wait(upTime);
- out5 = 0;
- out6 = 0;
- out7 = 0;
- out8 = 0;
+ setValve(UP, 0);
wait(waitTime);
- out1 = 1;
- out2 = 1;
- out3 = 1;
- out4 = 1;
+ setValve(DOWN, 1);
wait(downTime);
- out1 = 0;
- out2 = 0;
- out3 = 0;
- out4 = 0;
+ setValve(DOWN,0);
wait(waitTime);
- setLCDpos(1,1);
- lcd.printf("CURRENT COUNT IS");
- setLCDpos(2,1);
- lcd.printf(" ");
- setLCDpos(2,1);
- lcd.printf("%d",count);
+
+ count++;
+ printCount(count);
} else if (count>target) {
clearLCD();
setLCDpos(1,1);
@@ -276,8 +266,5 @@
wait(0.1);
}
}
- /*
- setLCDpos(2,9);
- lcd.printf("#%7i",i);*/
}