![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Isme LDR ya Pot ka value print hotai, l ye p type karne pe. Kuch aur type kia to kuch nai hotai.
Dependencies: mbed
main.cpp
- Committer:
- akashlal
- Date:
- 2016-07-01
- Revision:
- 0:d5eb245951cf
File content as of revision 0:d5eb245951cf:
#include "mbed.h" Serial pc(USBTX,USBRX); AnalogIn pot(PTB0); AnalogIn ldr(PTB1); float potf; //Declaring float value for Potentiometer reading int poti; //Declaring int value for Potentiometer reading float ldrf; //Declaring float value for LDR reading int ldri; //Declaring Integer value for LDR reading char i; int main() { while(1) { if(pc.readable()) { i=pc.getc(); if(i=='l') { ldrf=ldr.read(); ldri=ldrf*1000; pc.printf("LDR value is %d \n\r",ldri); } if(i=='p') { potf=pot.read(); poti=potf*3.3*1000; pc.printf("Pot value is %d \n\r",poti); } } wait(0.5); } }