Charles Tritt / Mbed 2 deprecated analog2pwm_Overloads

Dependencies:   mbed

Revision:
0:beed38f52072
Child:
1:6ec73385ba1f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 27 12:48:45 2017 +0000
@@ -0,0 +1,31 @@
+/*
+    Project: analog2pwm_Overloads
+    File: main.cpp
+
+    Reads from analog input, streams ASCII text to std serial using printf and
+    and proportionally lights onboard LED. Also demonstrates floating point 
+    literal sufix to eliminate warning and overloaded operators.
+
+    Written by: Dr. C. S. Tritt
+    Created: 3/27/17 (v. 1.0)
+
+*/
+#include "mbed.h"
+
+AnalogIn analog_value(A0);
+
+PwmOut led(LED1);
+
+int main()
+{
+    float value; // Value to be read and sent to serial port.
+
+    printf("\nAnalog to PWM example.\n");
+
+    while(true) {
+        value = analog_value; // Read the analog input value (0 to 1)
+        printf("Value = %f\n", value); // Send value as text via serial port.
+        led = value; // Proportionally light LED.
+        wait(0.25); // 250 ms
+    }
+}