control LED by CdS http://shokai.org/blog/archives/5103

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
shokai
Date:
Wed Apr 21 08:32:52 2010 +0000
Child:
1:83f0bc743127
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 21 08:32:52 2010 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+DigitalOut led1(LED1);
+DigitalOut led2(p11);
+AnalogIn adc(p15);
+int ain;
+
+int main() {
+    while(1) {
+        if(led1){
+          led1 = 0;
+        }
+        else{
+          led1 = 1;
+        }
+        ain = adc;
+        if(adc < 0.4){
+          led2 = 1;
+        }
+        else{
+          led2 = 0;
+        }
+        pc.printf("%f", (double)adc);
+        pc.printf("\r\n");
+        wait(0.3);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Apr 21 08:32:52 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0