Joshua Liu
/
GloveBoxTester
glovebox tester
Fork of GloveBoxTester by
GloveBoxTester.cpp@4:9d0aa204aa20, 2014-02-28 (annotated)
- Committer:
- joliu
- Date:
- Fri Feb 28 22:26:30 2014 +0000
- Revision:
- 4:9d0aa204aa20
- Parent:
- 3:ae51b59d29b8
Glovebox
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kzampag | 0:4c49d95a1f05 | 1 | #include "mbed.h" |
kzampag | 0:4c49d95a1f05 | 2 | |
joliu | 4:9d0aa204aa20 | 3 | Serial pc(USBTX, USBRX); |
kzampag | 0:4c49d95a1f05 | 4 | Serial lcd(p13,p14); |
kzampag | 0:4c49d95a1f05 | 5 | |
joliu | 4:9d0aa204aa20 | 6 | DigitalOut pn1(p25); |
joliu | 4:9d0aa204aa20 | 7 | DigitalOut pn2(p26); |
kzampag | 0:4c49d95a1f05 | 8 | DigitalOut box1(p23); |
kzampag | 0:4c49d95a1f05 | 9 | DigitalOut box2(p22); |
kzampag | 0:4c49d95a1f05 | 10 | DigitalOut box3(p21); |
kzampag | 3:ae51b59d29b8 | 11 | DigitalIn pause(p6); |
kzampag | 3:ae51b59d29b8 | 12 | |
kzampag | 3:ae51b59d29b8 | 13 | void clearLCD() |
kzampag | 3:ae51b59d29b8 | 14 | { |
kzampag | 3:ae51b59d29b8 | 15 | lcd.printf("%c%c",0xFE,0x01); |
kzampag | 3:ae51b59d29b8 | 16 | } |
kzampag | 3:ae51b59d29b8 | 17 | void setLCDpos(int xpos, int ypos) |
kzampag | 3:ae51b59d29b8 | 18 | { |
kzampag | 3:ae51b59d29b8 | 19 | int pos = 0x80; |
kzampag | 3:ae51b59d29b8 | 20 | switch (xpos) { |
kzampag | 3:ae51b59d29b8 | 21 | case 1: |
kzampag | 3:ae51b59d29b8 | 22 | pos +=0; |
kzampag | 3:ae51b59d29b8 | 23 | break; |
kzampag | 3:ae51b59d29b8 | 24 | case 2: |
kzampag | 3:ae51b59d29b8 | 25 | pos +=64; |
kzampag | 3:ae51b59d29b8 | 26 | break; |
kzampag | 3:ae51b59d29b8 | 27 | case 3: |
kzampag | 3:ae51b59d29b8 | 28 | pos +=20; |
kzampag | 3:ae51b59d29b8 | 29 | break; |
kzampag | 3:ae51b59d29b8 | 30 | case 4: |
kzampag | 3:ae51b59d29b8 | 31 | pos +=84; |
kzampag | 3:ae51b59d29b8 | 32 | break; |
kzampag | 3:ae51b59d29b8 | 33 | } |
kzampag | 3:ae51b59d29b8 | 34 | pos += (ypos-1); |
kzampag | 3:ae51b59d29b8 | 35 | lcd.printf("%c%c",0xFE,pos); |
kzampag | 3:ae51b59d29b8 | 36 | } |
kzampag | 3:ae51b59d29b8 | 37 | void setBrightness(int lev) |
kzampag | 3:ae51b59d29b8 | 38 | { |
kzampag | 3:ae51b59d29b8 | 39 | lcd.printf("%c%c",0xFE,lev+127); |
kzampag | 3:ae51b59d29b8 | 40 | |
kzampag | 3:ae51b59d29b8 | 41 | wait(.1); |
kzampag | 3:ae51b59d29b8 | 42 | } |
kzampag | 3:ae51b59d29b8 | 43 | //End LCD Setup |
kzampag | 0:4c49d95a1f05 | 44 | |
kzampag | 0:4c49d95a1f05 | 45 | |
kzampag | 0:4c49d95a1f05 | 46 | int count = 1; |
joliu | 4:9d0aa204aa20 | 47 | int cycles = 3500; |
kzampag | 3:ae51b59d29b8 | 48 | int check = 0; |
kzampag | 0:4c49d95a1f05 | 49 | |
kzampag | 0:4c49d95a1f05 | 50 | |
kzampag | 0:4c49d95a1f05 | 51 | |
kzampag | 0:4c49d95a1f05 | 52 | int main() |
kzampag | 0:4c49d95a1f05 | 53 | { |
joliu | 4:9d0aa204aa20 | 54 | //clearLCD(); |
joliu | 4:9d0aa204aa20 | 55 | //setLCDpos(1,1); |
joliu | 4:9d0aa204aa20 | 56 | //lcd.printf("Here we go!"); |
kzampag | 3:ae51b59d29b8 | 57 | while(count< cycles) { |
kzampag | 3:ae51b59d29b8 | 58 | if (pause) { |
kzampag | 3:ae51b59d29b8 | 59 | check = 1; |
joliu | 4:9d0aa204aa20 | 60 | |
joliu | 4:9d0aa204aa20 | 61 | //Trigger Gloveboxes |
kzampag | 3:ae51b59d29b8 | 62 | box1 = 1; |
kzampag | 3:ae51b59d29b8 | 63 | box2 = 0; |
kzampag | 3:ae51b59d29b8 | 64 | box3 = 0; |
joliu | 4:9d0aa204aa20 | 65 | wait(.15); |
kzampag | 3:ae51b59d29b8 | 66 | box1 = 0; |
kzampag | 3:ae51b59d29b8 | 67 | box2 = 1; |
joliu | 4:9d0aa204aa20 | 68 | box3 = 0; |
joliu | 4:9d0aa204aa20 | 69 | wait(.15); |
joliu | 4:9d0aa204aa20 | 70 | box1 = 0; |
kzampag | 3:ae51b59d29b8 | 71 | box2 = 0; |
kzampag | 3:ae51b59d29b8 | 72 | box3 = 1; |
joliu | 4:9d0aa204aa20 | 73 | wait(.15); |
joliu | 4:9d0aa204aa20 | 74 | box1 = 0; |
joliu | 4:9d0aa204aa20 | 75 | box2 = 0; |
kzampag | 3:ae51b59d29b8 | 76 | box3 = 0; |
joliu | 4:9d0aa204aa20 | 77 | wait(1.5); |
joliu | 4:9d0aa204aa20 | 78 | //Cylinders Up |
joliu | 4:9d0aa204aa20 | 79 | pn1 = 1; |
joliu | 4:9d0aa204aa20 | 80 | pn2 = 0; |
joliu | 4:9d0aa204aa20 | 81 | wait(1); |
joliu | 4:9d0aa204aa20 | 82 | //Cylinders Down |
joliu | 4:9d0aa204aa20 | 83 | pn1 = 0; |
joliu | 4:9d0aa204aa20 | 84 | pn2 = 1; |
kzampag | 3:ae51b59d29b8 | 85 | wait(.5); |
joliu | 4:9d0aa204aa20 | 86 | //Cylinders Off |
joliu | 4:9d0aa204aa20 | 87 | pn1 =0; |
joliu | 4:9d0aa204aa20 | 88 | pn2 =0; |
joliu | 4:9d0aa204aa20 | 89 | //Wait to repeat |
joliu | 4:9d0aa204aa20 | 90 | wait(2); |
kzampag | 3:ae51b59d29b8 | 91 | |
kzampag | 3:ae51b59d29b8 | 92 | count++; |
joliu | 4:9d0aa204aa20 | 93 | //setLCDpos(2,1); |
joliu | 4:9d0aa204aa20 | 94 | //lcd.printf("%d",count); |
joliu | 4:9d0aa204aa20 | 95 | pc.printf("%d",count); |
kzampag | 3:ae51b59d29b8 | 96 | } |
kzampag | 3:ae51b59d29b8 | 97 | else { |
kzampag | 3:ae51b59d29b8 | 98 | check = 0; |
kzampag | 3:ae51b59d29b8 | 99 | } |
kzampag | 2:73be4f9f04f9 | 100 | |
joliu | 4:9d0aa204aa20 | 101 | //setLCDpos(3,1); |
joliu | 4:9d0aa204aa20 | 102 | //lcd.printf("%d", check); |
kzampag | 3:ae51b59d29b8 | 103 | } |
kzampag | 0:4c49d95a1f05 | 104 | } |