![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
testing n-bed
main.cpp@0:8cd63f1ec3c9, 2015-01-22 (annotated)
- Committer:
- chalikias
- Date:
- Thu Jan 22 14:50:37 2015 +0000
- Revision:
- 0:8cd63f1ec3c9
- Child:
- 1:998fdef84813
connector K tested using LCD functionality
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chalikias | 0:8cd63f1ec3c9 | 1 | // N.C. testing n-bed LCD |
chalikias | 0:8cd63f1ec3c9 | 2 | |
chalikias | 0:8cd63f1ec3c9 | 3 | |
chalikias | 0:8cd63f1ec3c9 | 4 | #include "mbed.h" |
chalikias | 0:8cd63f1ec3c9 | 5 | #include "TextLCD.h" |
chalikias | 0:8cd63f1ec3c9 | 6 | |
chalikias | 0:8cd63f1ec3c9 | 7 | //n-bed CONNECTOR "L" JP6 |
chalikias | 0:8cd63f1ec3c9 | 8 | TextLCD lcd(p17, p20, p24, p23, p22, p8, TextLCD::LCD20x4); // rs, e, d4-d7 |
chalikias | 0:8cd63f1ec3c9 | 9 | |
chalikias | 0:8cd63f1ec3c9 | 10 | //n-bed CONNECTOR "K" JP7 |
chalikias | 0:8cd63f1ec3c9 | 11 | //Drive LCD from NON mbed pins |
chalikias | 0:8cd63f1ec3c9 | 12 | TextLCD lcd2(P1_19, P1_22, p15, P1_25, P1_26, P1_27, TextLCD::LCD20x4); // rs, e, d4-d7 |
chalikias | 0:8cd63f1ec3c9 | 13 | |
chalikias | 0:8cd63f1ec3c9 | 14 | Timer t; |
chalikias | 0:8cd63f1ec3c9 | 15 | DigitalOut led1(LED1); |
chalikias | 0:8cd63f1ec3c9 | 16 | |
chalikias | 0:8cd63f1ec3c9 | 17 | //Measure from a NON mbed analog pin |
chalikias | 0:8cd63f1ec3c9 | 18 | AnalogIn input(P0_2); //the range of the analog input goes, from 0 V. to 3.3V. the actual value is represented as a float from 0 to 1. |
chalikias | 0:8cd63f1ec3c9 | 19 | float ain; //ain must be a float, for matching the input.read type. |
chalikias | 0:8cd63f1ec3c9 | 20 | |
chalikias | 0:8cd63f1ec3c9 | 21 | int main() { |
chalikias | 0:8cd63f1ec3c9 | 22 | t.start(); |
chalikias | 0:8cd63f1ec3c9 | 23 | lcd.cls(); |
chalikias | 0:8cd63f1ec3c9 | 24 | wait(1); |
chalikias | 0:8cd63f1ec3c9 | 25 | lcd.printf("Hello LCD World!\n"); lcd2.printf("Hello 2ND Display\n"); |
chalikias | 0:8cd63f1ec3c9 | 26 | while (1) { |
chalikias | 0:8cd63f1ec3c9 | 27 | led1 = 1; |
chalikias | 0:8cd63f1ec3c9 | 28 | ain=input.read(); |
chalikias | 0:8cd63f1ec3c9 | 29 | lcd.locate(0,2); lcd2.locate(0,2); |
chalikias | 0:8cd63f1ec3c9 | 30 | lcd.printf("%1.1f mhnVolt", ( float(3.3)*ain) ) ; lcd2.printf("%1.1f mhnVolt", ( float(3.3)*ain) ) ; |
chalikias | 0:8cd63f1ec3c9 | 31 | wait(0.001); |
chalikias | 0:8cd63f1ec3c9 | 32 | ain=input.read(); |
chalikias | 0:8cd63f1ec3c9 | 33 | lcd.locate(0,3); lcd2.locate(0,3); |
chalikias | 0:8cd63f1ec3c9 | 34 | lcd.printf("%1.1f Volt", ( float(3.3)*ain) ) ; lcd2.printf("%1.1f Volt", ( float(3.3)*ain) ) ; |
chalikias | 0:8cd63f1ec3c9 | 35 | led1 = 0; |
chalikias | 0:8cd63f1ec3c9 | 36 | wait(0.9); |
chalikias | 0:8cd63f1ec3c9 | 37 | } |
chalikias | 0:8cd63f1ec3c9 | 38 | } |
chalikias | 0:8cd63f1ec3c9 | 39 | |
chalikias | 0:8cd63f1ec3c9 | 40 | |
chalikias | 0:8cd63f1ec3c9 | 41 | |
chalikias | 0:8cd63f1ec3c9 | 42 |