![](/media/cache/profiles/3b56beb4fb3143ab7f05335134909435.50x50_q85.jpg)
AnalogIn to p15 ~ LCD STEM UBC 2014
main.cpp@1:37e83b329c50, 2014-07-12 (annotated)
- Committer:
- chapfohn
- Date:
- Sat Jul 12 21:32:38 2014 +0000
- Revision:
- 1:37e83b329c50
- Parent:
- 0:a56aae49b357
- Child:
- 2:dbdb78914b02
With LCD state indicator.; LDR voltage divider network fed into p15.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chapfohn | 0:a56aae49b357 | 1 | #include "mbed.h" |
chapfohn | 0:a56aae49b357 | 2 | #include "C12832_lcd.h" |
chapfohn | 0:a56aae49b357 | 3 | |
chapfohn | 0:a56aae49b357 | 4 | Serial pc(USBTX, USBRX); |
chapfohn | 0:a56aae49b357 | 5 | |
chapfohn | 0:a56aae49b357 | 6 | AnalogIn Ain(p15); |
chapfohn | 0:a56aae49b357 | 7 | C12832_LCD lcd; |
chapfohn | 0:a56aae49b357 | 8 | |
chapfohn | 0:a56aae49b357 | 9 | float ADCdata; |
chapfohn | 0:a56aae49b357 | 10 | int main() |
chapfohn | 0:a56aae49b357 | 11 | { |
chapfohn | 0:a56aae49b357 | 12 | |
chapfohn | 0:a56aae49b357 | 13 | while (1) { |
chapfohn | 0:a56aae49b357 | 14 | |
chapfohn | 0:a56aae49b357 | 15 | ADCdata=Ain; |
chapfohn | 0:a56aae49b357 | 16 | |
chapfohn | 0:a56aae49b357 | 17 | wait (0.5); |
chapfohn | 0:a56aae49b357 | 18 | |
chapfohn | 0:a56aae49b357 | 19 | lcd.cls();//clear LCD for next reading round |
chapfohn | 0:a56aae49b357 | 20 | lcd.locate(3,3);//first LCD column label |
chapfohn | 0:a56aae49b357 | 21 | lcd.printf("%1.3f\n\r",ADCdata);//print data; |
chapfohn | 1:37e83b329c50 | 22 | if (ADCdata < (0.5)) { |
chapfohn | 1:37e83b329c50 | 23 | lcd.locate(3,12); |
chapfohn | 1:37e83b329c50 | 24 | lcd.printf("DARK"); |
chapfohn | 1:37e83b329c50 | 25 | } else { |
chapfohn | 1:37e83b329c50 | 26 | lcd.locate(3,12); |
chapfohn | 1:37e83b329c50 | 27 | lcd.printf("LIGHT"); |
chapfohn | 1:37e83b329c50 | 28 | } |
chapfohn | 0:a56aae49b357 | 29 | } |
chapfohn | 0:a56aae49b357 | 30 | } |