Abhinav Arasu / Mbed 2 deprecated led_determine

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 DigitalOut led1(LED1);
00004 DigitalOut led2(LED2);
00005 DigitalOut led3(LED3);
00006 DigitalOut led4(LED4);
00007 AnalogIn pot(p20);
00008 Serial pc(USBTX,USBRX);
00009  int main() {
00010 float x;
00011 x=pot.read();
00012 if(x<=0.2)
00013 {
00014 led1=led2=led3=led4=0;
00015 pc.printf("\nNo LED is glowing");       
00016 }
00017 else if(x<=0.4 && x>0.2)
00018 {
00019 led1=1;pc.printf("\nLED1  is glowing");       
00020 }
00021 else if(x<=0.6&& x>0.4)
00022 {
00023 led1=1;
00024 led2=1;pc.printf("\nLED1,2  are glowing");       
00025 }
00026 else if(x<=0.8 && x>0.6)
00027 {
00028 led1=led2=led3=1;pc.printf("\nLED1,2,3 are glowing");       
00029 
00030 }
00031 else if(x<=1 && x>0.8)
00032 {
00033 led1=led2=led3=led4=1;pc.printf("\nAll LEDs are glowing");       
00034 }
00035 pc.printf("\nthe value is %f",x);       
00036 }