Seeedstudio Arch Examples : Analog - Potentiometer example

Dependencies:   mbed

Revision:
0:b1a8b240b3a2
Child:
1:f81ab0473843
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 07 05:36:52 2013 +0000
@@ -0,0 +1,17 @@
+#include "mbed.h"
+
+AnalogIn pot(P0_11);   /* Potentiometer middle pin connected to P0_11, other two ends connected to GND and 3.3V */
+DigitalOut led(LED1);  /* LED blinks with a delay based on the analog input read */
+
+int main()
+{
+    float ain;
+
+    while(1) {
+        ain = pot.read(); /* Read analog value (output will be any value between 0 and 1 */
+        led = 1;          /* Switch ON LED        */  
+        wait(ain);        /* Wait for ain Seconds (maximum delay is 1 seconds)*/ 
+        led = 0;          /* Switch Off LED       */    
+        wait(ain);        /* Wait for ain Seconds (maximum delay is 1 seconds)*/ 
+    }
+}