PWM BASED LED BRIGHTNESS CONTROL -- MBED_OS PLATFORM AND USE OF PWM FUNCTION DUTY AND PERIOD BASIC FUNCTION USAGES & SETTINGS STM32 NUCLEO-64 IS TARGET BOARD CREATED BY : JAYDEEP SHAH --radhey04ec@gmail.com

Committer:
radhey04ec
Date:
Thu Jul 09 06:25:50 2020 +0000
Revision:
0:3af983412d3e
PWM Basic Program; DUTY CYCLE & period management; On board LED BRIGHTNESS CONTROL; JAYDEEP SHAH; radhey04ec@gmail.com

Who changed what in which revision?

UserRevisionLine numberNew contents of line
radhey04ec 0:3af983412d3e 1 //PWM BASIC FUNCTION USAGES IN MBED AND STM DEMO
radhey04ec 0:3af983412d3e 2 //JAYDEEP SHAH
radhey04ec 0:3af983412d3e 3 //radhey04ec@gmail.com
radhey04ec 0:3af983412d3e 4 //LED BRIGHTNESS CONTROL
radhey04ec 0:3af983412d3e 5 //CHANGE THE write() value to change the brightness / Duty cycle changes
radhey04ec 0:3af983412d3e 6 //On board led DEMO
radhey04ec 0:3af983412d3e 7
radhey04ec 0:3af983412d3e 8 //LIBRARY REQUIREMENT
radhey04ec 0:3af983412d3e 9 #include "mbed.h"
radhey04ec 0:3af983412d3e 10 //#include "platform/mbed_thread.h" // We do not need thread management lib now
radhey04ec 0:3af983412d3e 11
radhey04ec 0:3af983412d3e 12 //MAIN LOOP
radhey04ec 0:3af983412d3e 13 int main()
radhey04ec 0:3af983412d3e 14 {
radhey04ec 0:3af983412d3e 15 // Initialise the digital pin LED1 as an output
radhey04ec 0:3af983412d3e 16 PwmOut led(LED3); // object ated that deal with pin LED3
radhey04ec 0:3af983412d3e 17 led.period_ms(10); //PERIOD in mili second --FREQUENCY
radhey04ec 0:3af983412d3e 18 led.write(0.1f); // Duty cycle 10% // Change this value to change LED brightness
radhey04ec 0:3af983412d3e 19
radhey04ec 0:3af983412d3e 20 while (true) {
radhey04ec 0:3af983412d3e 21
radhey04ec 0:3af983412d3e 22
radhey04ec 0:3af983412d3e 23 }
radhey04ec 0:3af983412d3e 24 }