Write a program to control an LED brightness by generating a PWM signal on PIC18 series microcontroller

Procedure

Simulator :
  • step 1 : Select Output Pin.
  • step 2 : Select PWM Period value (mS).
  • step 3 : Select Duty Cycle (10% - 100%).
  • step 4 : Select LED Configuration.
  • step 5 : Click on "GENERATE CODE" button to generate code.
  • step 6 : Click on "COMPILE" button to compile code.
  • step 7 : Click on "EXECUTE" button to execute code and goto mimic.
  • step 8 : If you want to download code click on "DOWNLOAD" button.
  • step 9 : The MIMIC will open on left side of screen.
  • step 10 : Click on selected output pin terminal(red circle) and click on anode terminal(red circle) for connection of the selected output pin to anode or vice versa.
  • step 11 : Click on cathode terminal(red circle) and click on resistor terminal(red circle) for connection of cathode to resister or vice versa.
  • step 12 : Click on "Check Connection" button.
  • step 13 : If connection is wrong, click on "Reset Connection" button and follow steps 10,11 and 12.
  • step 14 : If connection is successful, click on "Run" Button.
  • step 15 : Output LED is on. Observe the square wave graph.
  • step 16 : Click on "REFRESH" button to re-executing the experiment.