ADC values ported on to LCD

Dependencies:   TextLCD mbed

Fork of TextLCD_HelloWorld by Srinivasan Ramasamy

Committer:
Pallavi
Date:
Mon May 06 07:26:47 2013 +0000
Revision:
4:206beeaf992b
Parent:
3:bae19bde97d5
interactive adc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 1:7418a52375a0 1 // Hello World! for the TextLCD
simon 1:7418a52375a0 2
simon 0:334327d1a416 3 #include "mbed.h"
simon 0:334327d1a416 4 #include "TextLCD.h"
simon 0:334327d1a416 5
Pallavi 4:206beeaf992b 6 TextLCD lcd(p9, p10, p11, p12, p13, p14); // rs, e, d4-d7
Pallavi 4:206beeaf992b 7 AnalogIn voltage(p15);
Pallavi 4:206beeaf992b 8 DigitalOut A(LED1);
Pallavi 4:206beeaf992b 9 DigitalOut B(LED2);
Pallavi 4:206beeaf992b 10 DigitalOut C(LED3);
Pallavi 4:206beeaf992b 11 DigitalOut D(LED4);
ramsphd 3:bae19bde97d5 12 int main()
ramsphd 3:bae19bde97d5 13 {
Pallavi 4:206beeaf992b 14 float x;
ramsphd 3:bae19bde97d5 15 while (1){
Pallavi 4:206beeaf992b 16 x=voltage.read();
Pallavi 4:206beeaf992b 17 lcd.printf(" voltage in real: %3.4f\n", voltage.read());
Pallavi 4:206beeaf992b 18 wait(1);
Pallavi 4:206beeaf992b 19 lcd.printf("voltage in integer: %5d\n", voltage.read_u16());
ramsphd 3:bae19bde97d5 20 wait(1);
Pallavi 4:206beeaf992b 21 if(x<=0.2)
Pallavi 4:206beeaf992b 22 {
Pallavi 4:206beeaf992b 23 A=0;
Pallavi 4:206beeaf992b 24 B=0;
Pallavi 4:206beeaf992b 25 C=0;
Pallavi 4:206beeaf992b 26 D=0;
Pallavi 4:206beeaf992b 27 }
Pallavi 4:206beeaf992b 28 else if(x>0.2 && x<=0.4)
Pallavi 4:206beeaf992b 29 {
Pallavi 4:206beeaf992b 30 A=1;
Pallavi 4:206beeaf992b 31 B=0;
Pallavi 4:206beeaf992b 32 C=0;
Pallavi 4:206beeaf992b 33 D=0;
Pallavi 4:206beeaf992b 34 }
Pallavi 4:206beeaf992b 35 else if(x>0.4 && x<=0.6)
Pallavi 4:206beeaf992b 36 {
Pallavi 4:206beeaf992b 37 A=1;
Pallavi 4:206beeaf992b 38 B=1;
Pallavi 4:206beeaf992b 39 C=0;
Pallavi 4:206beeaf992b 40 D=0;
Pallavi 4:206beeaf992b 41 }
Pallavi 4:206beeaf992b 42 else if(x>0.6 && x<=0.8)
Pallavi 4:206beeaf992b 43 {
Pallavi 4:206beeaf992b 44 A=1;
Pallavi 4:206beeaf992b 45 B=1;
Pallavi 4:206beeaf992b 46 C=1;
Pallavi 4:206beeaf992b 47 D=0;
Pallavi 4:206beeaf992b 48 }
Pallavi 4:206beeaf992b 49 else if(x>0.8 && x<=1.0)
Pallavi 4:206beeaf992b 50 {
Pallavi 4:206beeaf992b 51 A=1;
Pallavi 4:206beeaf992b 52 B=1;
Pallavi 4:206beeaf992b 53 C=1;
Pallavi 4:206beeaf992b 54 D=1;
Pallavi 4:206beeaf992b 55 }
simon 0:334327d1a416 56 }
ramsphd 3:bae19bde97d5 57 }