Lee Nam Cheol
/
lab02-led-dimmer
using DAC0_OUT to adjust the brightness of a led
main.cpp
- Committer:
- namcheol
- Date:
- 2020-04-15
- Revision:
- 1:aa352db03d0c
- Parent:
- 0:f31836d48420
File content as of revision 1:aa352db03d0c:
#include "mbed.h" AnalogOut led(DAC0_OUT); //led = DAC0_OUT int main() { float f; while (true) { for(f = 0.5; f <= 1.0; f += 0.01){ //led from 50% of brightness to 100% led.write(f); thread_sleep_for(3000/50); } for(f = 1.0; f >= 0.5; f -= 0.01){ //led from 100% to 50% led.write(f); thread_sleep_for(3000/50); } } }