Saturday, June 12, 2021

Arduino Simulator examples - "LED fading" -using AnalogWrite() 📉

Arduino "Fade an LED" on Arduino simulator

 Summary

Arduino "Fade an LED" Program fades an LED. The LED in this example is connected to pin 9 of the Arduino UNO. The fading is achieved by driving the LED at a constant PWM frequency but variable Duty cycle. The example is taken from standard builtin Arduino example. 

You can click on Run button in the simulator below to see the Arduino simulator in action. Wokwi Arduino simulator is used here as it is free and easy to use online. 

Warning🚨: Make sure you connect a resistor in series when you connect an LED to a real board. If not, you may damage the LED or the Board or worse, both!  

LED fading - Wokwi Arduino Simulator
Wokwi Arduino Simulator - AnalogWrite() function for LED fading

 

Tip✅: Red LEDs will have lower forward voltage compared to blue or white LEDs. Hence, Red LEDs need a higher value of resistor in series compared to a white LED for the same brightness.

You can do following things with the Arduino Simulator example

  • Add one more LED on pin 10 and make both LEDs fade together

Arduino Simulation

 In the section below, you can also modify the code and see the results instantly. You can change the code and recompile it by clicking on rerun/Run button. For more help, please visit Discord channel of the Wokwi Arduino Simulator. 

No comments:

Post a Comment

Be Nice Policy :)

Arduino IR simulator projects - "simple receiver"

Arduino "IR simple receiver" on Arduino simulator - IR remote project  Summary Arduino "simple receiver" is an Arduino p...