Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:25e9e904a1c8, committed 2019-10-25
- 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