Simple ADC tutorial using FRDM-KL25Z made by Twistx77 from TutoElectro

Dependencies:   mbed

Revision:
0:6c0fee4aea35
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jan 04 11:51:09 2015 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+
+AnalogIn LDR(A0);
+Serial pc(USBTX,USBRX);
+
+int main() {
+    
+    uint16_t adcValue;
+    float voltage;
+    
+    
+    pc.baud(115200);
+    
+    while(1) {
+        
+        adcValue = LDR.read_u16();
+        
+        voltage = adcValue *3.3 / 65535;
+        
+        pc.printf("ADC Value: %i, %.3f volts.\r\n", adcValue, voltage);
+        
+        wait(0.1);       
+        
+        
+    }
+}