PWM - pic18f4550 - led + potentiometer (simple project)

Thread Starter

Bellon

Joined Sep 19, 2015
9
Hello. I'm doing my first program with pwm and am encountering some difficulties to do a small project. I want to vary the voltage of an LED as the turning of a potentiometer. However, the examples I found are with PWM own libraries, which I have not. I'm using a PIC18F4550 in MPLAB X.

If anyone can help me, I will be very grateful.
 

dannyf

Joined Sep 13, 2015
2,197
1. can you do adc on your chip?
2. can you do pwm on your chip?

If you can do both, it is simple to integrate them;

if you cannot do either, start learning now.
 

jpanhalt

Joined Jan 18, 2008
11,087
If this is your first project, I suggest dividing it into two parts: 1) Setting up PWM to give, say, 40% duty cycle; and 2) Setting up the ADC to digitize your potentiometer output voltage (voltage divider) to control PR2, with which you can set the duty cycle. Do the first part, test it. Then proceed to the second.

John
 
Top