Oleksandr Malyuskin / Mbed 2 deprecated Nucleo_pwm

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
malyuskin
Date:
Fri Oct 25 02:19:35 2019 +0000
Commit message:
PWM output with duty cycle controlled by a potentiometer to change LED brightness

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
diff -r 000000000000 -r 25e9e904a1c8 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 25 02:19:35 2019 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h"
+
+PwmOut ledpwm(A6); // PWM signal out on pin A6
+
+AnalogIn analog_value(A0); // Analog in signal from potentiometer
+
+int main() {
+    float meas_r =0.0;
+    ledpwm.period_ms(10);        // period of PWM pulse 10ms
+    //mypwm.pulsewidth_ms(1);
+  
+      
+    while(1) {
+  
+  meas_r = analog_value.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
+  
+  ledpwm.write(meas_r);  // changing duty cycle in proportion to the read potentiometer value
+          
+    }
+}
+
diff -r 000000000000 -r 25e9e904a1c8 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 25 02:19:35 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file