![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
rev1
main.cpp@3:0c35cd39b8b1, 2020-07-14 (annotated)
- Committer:
- tonyk37
- Date:
- Tue Jul 14 14:54:33 2020 +0000
- Revision:
- 3:0c35cd39b8b1
- Parent:
- 2:a17516deccae
Final draft of project 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 | 2:a17516deccae | 6 | float value; //measured value |
tonyk37 | 2:a17516deccae | 7 | float weight; //process variable |
tonyk37 | 0:f6dbd5e25623 | 8 | AnalogIn pot1(p19); |
tonyk37 | 0:f6dbd5e25623 | 9 | DigitalOut led1(LED1); |
tonyk37 | 0:f6dbd5e25623 | 10 | DigitalOut led3(LED3); |
tonyk37 | 0:f6dbd5e25623 | 11 | DigitalOut led4(LED4); |
tonyk37 | 0:f6dbd5e25623 | 12 | int i; |
tonyk37 | 0:f6dbd5e25623 | 13 | |
tonyk37 | 0:f6dbd5e25623 | 14 | int main() { |
tonyk37 | 0:f6dbd5e25623 | 15 | while(1) { |
tonyk37 | 0:f6dbd5e25623 | 16 | value = pot1.read(); |
tonyk37 | 0:f6dbd5e25623 | 17 | weight = value*1500 ; |
tonyk37 | 0:f6dbd5e25623 | 18 | lcd.locate(0,0); |
tonyk37 | 0:f6dbd5e25623 | 19 | lcd.printf("weight %.2f", weight); |
tonyk37 | 2:a17516deccae | 20 | if (weight > 1230 && weight < 1360) //process target set point |
tonyk37 | 1:459034942ff5 | 21 | { |
tonyk37 | 2:a17516deccae | 22 | led1 = 1; //output signal for process beacon and cylinder |
tonyk37 | 0:f6dbd5e25623 | 23 | led3 = 0; |
tonyk37 | 1:459034942ff5 | 24 | led4 = 0; |
tonyk37 | 0:f6dbd5e25623 | 25 | |
tonyk37 | 1:459034942ff5 | 26 | lcd.locate(0,20); |
tonyk37 | 1:459034942ff5 | 27 | lcd.printf("TRUE"); |
tonyk37 | 1:459034942ff5 | 28 | wait(0.20); |
tonyk37 | 1:459034942ff5 | 29 | lcd.cls(); |
tonyk37 | 1:459034942ff5 | 30 | } |
tonyk37 | 0:f6dbd5e25623 | 31 | |
tonyk37 | 1:459034942ff5 | 32 | |
tonyk37 | 0:f6dbd5e25623 | 33 | if ( weight < 1229) |
tonyk37 | 0:f6dbd5e25623 | 34 | { |
tonyk37 | 0:f6dbd5e25623 | 35 | led1 = 0; |
tonyk37 | 0:f6dbd5e25623 | 36 | led4 = 0; |
tonyk37 | 2:a17516deccae | 37 | led3 = 1; // output signal for Red light on process beacon |
tonyk37 | 1:459034942ff5 | 38 | |
tonyk37 | 1:459034942ff5 | 39 | lcd.locate(0,20); |
tonyk37 | 1:459034942ff5 | 40 | lcd.printf("Missing QTY"); |
tonyk37 | 1:459034942ff5 | 41 | wait(0.20); |
tonyk37 | 1:459034942ff5 | 42 | lcd.cls(); |
tonyk37 | 1:459034942ff5 | 43 | |
tonyk37 | 0:f6dbd5e25623 | 44 | } |
tonyk37 | 0:f6dbd5e25623 | 45 | if ( weight > 1361) |
tonyk37 | 0:f6dbd5e25623 | 46 | { |
tonyk37 | 0:f6dbd5e25623 | 47 | led1 = 0; |
tonyk37 | 0:f6dbd5e25623 | 48 | led3 = 0; |
tonyk37 | 2:a17516deccae | 49 | led4 = 1; // output signal for Blue light on process beacon |
tonyk37 | 1:459034942ff5 | 50 | |
tonyk37 | 1:459034942ff5 | 51 | lcd.locate(0,20); |
tonyk37 | 1:459034942ff5 | 52 | lcd.printf("EXCESS QTY"); |
tonyk37 | 1:459034942ff5 | 53 | wait(0.20); |
tonyk37 | 1:459034942ff5 | 54 | lcd.cls(); |
tonyk37 | 1:459034942ff5 | 55 | |
tonyk37 | 1:459034942ff5 | 56 | } |
tonyk37 | 0:f6dbd5e25623 | 57 | |
tonyk37 | 0:f6dbd5e25623 | 58 | } |
tonyk37 | 0:f6dbd5e25623 | 59 | } |