,,,

Dependencies:   mbed

main.cpp

Committer:
anmolhardik
Date:
2017-02-09
Revision:
0:279ce6151af4

File content as of revision 0:279ce6151af4:

#include "mbed.h"

Serial pc (USBTX,USBRX);
BusOut led(PTB18,PTB19,PTD1);
AnalogIn pot (PTB0);
AnalogIn ldr  (PTB1);
int main ()
{
    char c;
    float v1=0,v2=0;
    while (1)
    {
        
        
        if(pc.readable())
        {
            c= pc.getc();
            
                  if(c=='p')
                  {
                       led=0x3;
                       v1= pot.read()*3.3;
                       pc.printf("pot=%0.2f\r\n",v1);
                       //pc.printf("blue on");
                  }
                 else if(c=='l')
                 {
                     led=0x6;
                     v2= ldr.read()*3.3;              
                     pc.printf("ldr=%0.2f \r\n",v2);
                     //pc.printf("red on");
                 }
            }
     }
}