Sudip Mandal
/
SensorValueDisplay
getting values from sensor and display those values on LCD
main.cpp@0:266105102052, 2016-11-03 (annotated)
- Committer:
- papuxtream
- Date:
- Thu Nov 03 06:44:28 2016 +0000
- Revision:
- 0:266105102052
Getting values from sensor and display it on LCD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
papuxtream | 0:266105102052 | 1 | #include "mbed.h" |
papuxtream | 0:266105102052 | 2 | #include "TextLCD.h" |
papuxtream | 0:266105102052 | 3 | |
papuxtream | 0:266105102052 | 4 | TextLCD lcd(p5,p6,p7,p8,p9,p10); |
papuxtream | 0:266105102052 | 5 | AnalogIn ldr(p15); |
papuxtream | 0:266105102052 | 6 | int main() |
papuxtream | 0:266105102052 | 7 | { |
papuxtream | 0:266105102052 | 8 | {lcd.cls(); |
papuxtream | 0:266105102052 | 9 | wait_ms(0.02); |
papuxtream | 0:266105102052 | 10 | lcd.locate(0,0); |
papuxtream | 0:266105102052 | 11 | lcd.printf("SENSOR OUTPUT VOLTAGE");} |
papuxtream | 0:266105102052 | 12 | |
papuxtream | 0:266105102052 | 13 | while(1) |
papuxtream | 0:266105102052 | 14 | {int ldr_value=ldr; |
papuxtream | 0:266105102052 | 15 | float voltage=ldr_value*(5.0/1023.0); |
papuxtream | 0:266105102052 | 16 | lcd.locate(1,1); |
papuxtream | 0:266105102052 | 17 | lcd.printf("%0.0f",voltage); |
papuxtream | 0:266105102052 | 18 | lcd.printf("Volt"); |
papuxtream | 0:266105102052 | 19 | } |
papuxtream | 0:266105102052 | 20 | |
papuxtream | 0:266105102052 | 21 | } |