Author Topic: led brightness control (using PWM)  (Read 1894 times)

0 Members and 1 Guest are viewing this topic.

Offline Farouk1920Topic starter

  • Newbie
  • Posts: 1
  • Country: tr
led brightness control (using PWM)
« on: December 05, 2016, 09:28:26 am »
Hello friends, my semester project in microprocessors course is an automatic control of a power led according to the light of day. it's required to use an LDR as a light sensor, a 16F877a pic microcontroller . in the class we still didn't take the PWM lesson but i don't have much time to do the project. I took a look at the internet and i understand its logic but i failed to write the xc8 for a pw module related to the analog input of the ldr.
can someone help me ???
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19494
  • Country: gb
  • 0999
Re: led brightness control (using PWM)
« Reply #1 on: December 05, 2016, 10:42:26 am »
Please post the code and the schematic.

It sounds quite straightforward, other than I don't have much experience with C. I'd use assembler for this and if I wanted a challange, I'd use an old MCU with no PWM module, such as the 16F505 and do the PWM in software.  >:D
 

Offline MrMetthew

  • Regular Contributor
  • *
  • Posts: 57
  • Country: ca
  • Where it all comes down to : i = c (dv/dt)
Re: led brightness control (using PWM)
« Reply #2 on: December 05, 2016, 12:21:02 pm »
For this simple project it would probably even be easier to write the pwm yoursels instead of figuring out how to use the pwm modulle. Anyway I'm assuming your a beginner in the world of micro controllers. I can give you a piece of advice that will really help you with reaching your goal. Read the datasheet, read the datasheet again and then read it some more :). Trust me PIC's have really good datasheets, but can be cumbersome to read for a beginner. You will need to figure out the ADC to measure the ldr sensor and the pwm modulle, and also need to add some very minimal "glue" C code. You can use of of the timer blocks as pwm modulle, I doubt they will actually be called PWM modulle in the datasheet.

If you're stuck with your code, just post it here!
 

Offline steaky1212

  • Regular Contributor
  • *
  • Posts: 95
  • Country: gb
    • Steaky - Sleep is overrated
Re: led brightness control (using PWM)
« Reply #3 on: December 06, 2016, 03:04:26 pm »
Have you assigned a timer to the PWM module?
 

Offline xack

  • Newbie
  • Posts: 5
  • Country: de
Re: led brightness control (using PWM)
« Reply #4 on: December 06, 2016, 09:37:34 pm »
Best would be if you do it like MrMetthew said.

But if you need a quick (and i think easy) tutorial, have a look at this Instructable (btw. first google result):
http://www.instructables.com/id/Generating-50Hz-PWM-Using-PIC16F877A/?ALLSTEPS
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf