Pallavi Sudhakar
/
TextLCD_ADC
ADC values ported on to LCD
Fork of TextLCD_HelloWorld by
Revision 4:206beeaf992b, committed 2013-05-06
- Comitter:
- Pallavi
- Date:
- Mon May 06 07:26:47 2013 +0000
- Parent:
- 3:bae19bde97d5
- Commit message:
- interactive adc
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Apr 13 07:03:04 2013 +0000 +++ b/main.cpp Mon May 06 07:26:47 2013 +0000 @@ -3,16 +3,55 @@ #include "mbed.h" #include "TextLCD.h" -TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7 - +TextLCD lcd(p9, p10, p11, p12, p13, p14); // rs, e, d4-d7 +AnalogIn voltage(p15); +DigitalOut A(LED1); +DigitalOut B(LED2); +DigitalOut C(LED3); +DigitalOut D(LED4); int main() { +float x; while (1){ - lcd.printf(" This is 16x2!\n"); - lcd.printf("Jello World!\n"); +x=voltage.read(); + lcd.printf(" voltage in real: %3.4f\n", voltage.read()); + wait(1); + lcd.printf("voltage in integer: %5d\n", voltage.read_u16()); wait(1); - lcd.printf("Jello World! \n"); - lcd.printf("Hello World!\n"); - wait(1); + if(x<=0.2) + { + A=0; + B=0; + C=0; + D=0; + } + else if(x>0.2 && x<=0.4) + { + A=1; + B=0; + C=0; + D=0; + } + else if(x>0.4 && x<=0.6) + { + A=1; + B=1; + C=0; + D=0; + } + else if(x>0.6 && x<=0.8) + { + A=1; + B=1; + C=1; + D=0; + } + else if(x>0.8 && x<=1.0) + { + A=1; + B=1; + C=1; + D=1; + } } }