Joshua Liu / Mbed 2 deprecated GloveBoxTester

Dependencies:   mbed

Fork of GloveBoxTester by Kyle Zampaglione

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GloveBoxTester.cpp Source File

GloveBoxTester.cpp

00001 #include "mbed.h"
00002 
00003 Serial pc(USBTX, USBRX);
00004 Serial lcd(p13,p14);
00005 
00006 DigitalOut pn1(p25);
00007 DigitalOut pn2(p26);
00008 DigitalOut box1(p23);
00009 DigitalOut box2(p22);
00010 DigitalOut box3(p21);
00011 DigitalIn  pause(p6);
00012 
00013 void clearLCD()
00014 {
00015     lcd.printf("%c%c",0xFE,0x01);
00016 }
00017 void setLCDpos(int xpos, int ypos)
00018 {
00019     int pos = 0x80;
00020     switch (xpos) {
00021         case 1:
00022             pos +=0;
00023             break;
00024         case 2:
00025             pos +=64;
00026             break;
00027         case 3:
00028             pos +=20;
00029             break;
00030         case 4:
00031             pos +=84;
00032             break;
00033     }
00034     pos += (ypos-1);
00035     lcd.printf("%c%c",0xFE,pos);
00036 }
00037 void setBrightness(int lev)
00038 {
00039     lcd.printf("%c%c",0xFE,lev+127);
00040 
00041     wait(.1);
00042 }
00043 //End LCD Setup
00044 
00045 
00046 int count = 1;
00047 int cycles = 3500;
00048 int check = 0;
00049 
00050 
00051 
00052 int main()
00053 {
00054     //clearLCD();
00055     //setLCDpos(1,1);
00056     //lcd.printf("Here we go!");
00057     while(count< cycles) {
00058         if (pause) {
00059             check = 1;
00060 
00061             //Trigger Gloveboxes
00062             box1 = 1;
00063             box2 = 0;
00064             box3 = 0;
00065             wait(.15);
00066             box1 = 0;
00067             box2 = 1;
00068             box3 = 0;
00069             wait(.15);
00070             box1 = 0;
00071             box2 = 0;
00072             box3 = 1;
00073             wait(.15);
00074             box1 = 0;
00075             box2 = 0;
00076             box3 = 0;
00077             wait(1.5);
00078             //Cylinders Up
00079             pn1 = 1;
00080             pn2 = 0;
00081             wait(1);
00082             //Cylinders Down
00083             pn1 = 0;
00084             pn2 = 1;
00085             wait(.5);
00086             //Cylinders Off
00087             pn1 =0;
00088             pn2 =0;
00089             //Wait to repeat
00090             wait(2);
00091           
00092             count++;
00093             //setLCDpos(2,1);
00094             //lcd.printf("%d",count);
00095             pc.printf("%d",count);
00096         }
00097         else {
00098             check = 0;
00099         }
00100 
00101         //setLCDpos(3,1);
00102         //lcd.printf("%d", check); 
00103     } 
00104 }