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

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Twistx77
Date:
Sun Jan 04 11:51:09 2015 +0000
Commit message:
Simple ADC tutorial using FRDM-KL25Z made by TutoElectro

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	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);       
+        
+        
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jan 04 11:51:09 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file