Search Code
About cds_led_serial

First published 21 Apr 2010, with 2 revisions since.
Last update: 22 Apr 2010.
View history

Last change message: N/A

Import this program

cds_led_serial

Published 22 Apr 2010, by   user sho hashimoto   tag adc, cds
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 Serial pc(USBTX, USBRX);
00004 
00005 DigitalOut led1(LED1); // on board LED
00006 DigitalOut led2(p11);
00007 AnalogIn adc(p15);
00008 float ain;
00009 
00010 int main() {
00011     while(1) {
00012         led1 = !led1; // blink LED
00013         ain = adc;
00014         if(ain < 0.4) led2 = 1;
00015         else led2 = 0;
00016         pc.printf("%f\r\n", (float)ain);
00017         wait(0.3);
00018     }
00019 }