![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
rev1
main.cpp@2:a17516deccae, 2020-07-13 (annotated)
- Committer:
- tonyk37
- Date:
- Mon Jul 13 14:41:30 2020 +0000
- Revision:
- 2:a17516deccae
- Parent:
- 1:459034942ff5
- Child:
- 3:0c35cd39b8b1
finished project for Instrumentation July 2020
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tonyk37 | 0:f6dbd5e25623 | 1 | #include "mbed.h" |
tonyk37 | 0:f6dbd5e25623 | 2 | #include "C12832.h" |
tonyk37 | 0:f6dbd5e25623 | 3 | |
tonyk37 | 0:f6dbd5e25623 | 4 | |
tonyk37 | 0:f6dbd5e25623 | 5 | C12832 lcd(p5, p7, p6, p8, p11); |
tonyk37 | 0:f6dbd5e25623 | 6 | Serial pc(USBTX, USBRX); // tx, rx |
tonyk37 | 2:a17516deccae | 7 | float value; //measured value |
tonyk37 | 2:a17516deccae | 8 | float weight; //process variable |
tonyk37 | 0:f6dbd5e25623 | 9 | AnalogIn pot1(p19); |
tonyk37 | 0:f6dbd5e25623 | 10 | DigitalOut led1(LED1); |
tonyk37 | 0:f6dbd5e25623 | 11 | DigitalOut led3(LED3); |
tonyk37 | 0:f6dbd5e25623 | 12 | DigitalOut led4(LED4); |
tonyk37 | 0:f6dbd5e25623 | 13 | int i; |
tonyk37 | 0:f6dbd5e25623 | 14 | |
tonyk37 | 0:f6dbd5e25623 | 15 | int main() { |
tonyk37 | 0:f6dbd5e25623 | 16 | while(1) { |
tonyk37 | 0:f6dbd5e25623 | 17 | value = pot1.read(); |
tonyk37 | 0:f6dbd5e25623 | 18 | weight = value*1500 ; |
tonyk37 | 0:f6dbd5e25623 | 19 | lcd.locate(0,0); |
tonyk37 | 0:f6dbd5e25623 | 20 | lcd.printf("weight %.2f", weight); |
tonyk37 | 2:a17516deccae | 21 | if (weight > 1230 && weight < 1360) //process target set point |
tonyk37 | 1:459034942ff5 | 22 | { |
tonyk37 | 2:a17516deccae | 23 | led1 = 1; //output signal for process beacon and cylinder |
tonyk37 | 0:f6dbd5e25623 | 24 | led3 = 0; |
tonyk37 | 1:459034942ff5 | 25 | led4 = 0; |
tonyk37 | 0:f6dbd5e25623 | 26 | |
tonyk37 | 1:459034942ff5 | 27 | lcd.locate(0,20); |
tonyk37 | 1:459034942ff5 | 28 | lcd.printf("TRUE"); |
tonyk37 | 1:459034942ff5 | 29 | wait(0.20); |
tonyk37 | 1:459034942ff5 | 30 | lcd.cls(); |
tonyk37 | 1:459034942ff5 | 31 | } |
tonyk37 | 0:f6dbd5e25623 | 32 | |
tonyk37 | 1:459034942ff5 | 33 | |
tonyk37 | 0:f6dbd5e25623 | 34 | if ( weight < 1229) |
tonyk37 | 0:f6dbd5e25623 | 35 | { |
tonyk37 | 0:f6dbd5e25623 | 36 | led1 = 0; |
tonyk37 | 0:f6dbd5e25623 | 37 | led4 = 0; |
tonyk37 | 2:a17516deccae | 38 | led3 = 1; // output signal for Red light on process beacon |
tonyk37 | 1:459034942ff5 | 39 | |
tonyk37 | 1:459034942ff5 | 40 | lcd.locate(0,20); |
tonyk37 | 1:459034942ff5 | 41 | lcd.printf("Missing QTY"); |
tonyk37 | 1:459034942ff5 | 42 | wait(0.20); |
tonyk37 | 1:459034942ff5 | 43 | lcd.cls(); |
tonyk37 | 1:459034942ff5 | 44 | |
tonyk37 | 0:f6dbd5e25623 | 45 | } |
tonyk37 | 0:f6dbd5e25623 | 46 | if ( weight > 1361) |
tonyk37 | 0:f6dbd5e25623 | 47 | { |
tonyk37 | 0:f6dbd5e25623 | 48 | led1 = 0; |
tonyk37 | 0:f6dbd5e25623 | 49 | led3 = 0; |
tonyk37 | 2:a17516deccae | 50 | led4 = 1; // output signal for Blue light on process beacon |
tonyk37 | 1:459034942ff5 | 51 | |
tonyk37 | 1:459034942ff5 | 52 | lcd.locate(0,20); |
tonyk37 | 1:459034942ff5 | 53 | lcd.printf("EXCESS QTY"); |
tonyk37 | 1:459034942ff5 | 54 | wait(0.20); |
tonyk37 | 1:459034942ff5 | 55 | lcd.cls(); |
tonyk37 | 1:459034942ff5 | 56 | |
tonyk37 | 1:459034942ff5 | 57 | } |
tonyk37 | 0:f6dbd5e25623 | 58 | |
tonyk37 | 0:f6dbd5e25623 | 59 | } |
tonyk37 | 0:f6dbd5e25623 | 60 | } |