Adjust the brightness of a LED using potmeter input and FastPWM output

Dependencies:   FastPWM mbed

Files at this revision

API Documentation at this revision

Comitter:
sjoerdbarts
Date:
Fri Oct 07 09:43:52 2016 +0000
Parent:
0:fe2a62ab1017
Commit message:
Reduce duty cycle to 50 Hz

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Oct 07 09:41:40 2016 +0000
+++ b/main.cpp	Fri Oct 07 09:43:52 2016 +0000
@@ -15,8 +15,8 @@
 
 // Initial duty value and period
 volatile float duty = 0.0;
-volatile float frequency = 100.0;
-const int Timeset_duty_cycle = 1000;
+volatile float frequency_pwm = 100.0;
+const int Timeset_duty_cycle = 50;
 
 void set_dutycycle() {
     duty=pot.read();
@@ -35,7 +35,7 @@
     tick_set_brightness.attach(set_dutycycle,1/Timeset_duty_cycle);
     
     // Set period of LED
-    led.period(1.0/frequency);
+    led.period(1.0/frequency_pwm);
     
     while(true){