Results 1 to 10 of 10

Thread: Push botton dimmer

  1. #1

    Default Push botton dimmer

    I am new to microcontrollers. I am going to build my first project "Push button controlled PWM" using PIC12F675 for dimming LEDs.

    I want to control the duty cycle of 100Hz pulse from 0-100%.
    Two pushbuttons, one for increment and another for decrement of duty cycle.
    Resolution required is in steps of 2%.

    Kindly help me with code.

    Don't have knowledge and experience of programming.

    Thx.
    ashwal.patel@gmail.com

  2. #2
    Join Date
    May 2007
    Posts
    4,125

    Default Re: Push botton dimmer

    Sounds like an assignment for an electronics or microprocessor lab class.
    Phil

  3. #3
    Join Date
    Jan 2008
    Location
    Malden MA
    Posts
    794

    Default Re: Push botton dimmer

    The trick is to approach this in stages. First get the LED to blink. Then add PWM dimming at a constant rate. Then add the code to change the dim value (ramp it up and down at a slow rate for testing). Finally, add the buttons and debouncing code.

    If you have specific code questions, post the code and someone may be able to help out (sorry , I'm an Atmel person myself).

    /mike

  4. #4
    Join Date
    Aug 2008
    Location
    Plainview, Mn
    Posts
    1,073

    Default Re: Push botton dimmer

    Quote Originally Posted by P. Short View Post
    Sounds like an assignment for an electronics or microprocessor lab class.
    I would guess you are right. Considering the number of posts of the user, it appears assistance with homework is the goal here.
    HA, somebody else is putting up my lights this year.

  5. #5
    Join Date
    Nov 2007
    Location
    Middle Earth
    Posts
    2,251

    Default Re: Push botton dimmer

    Quote Originally Posted by ashwal View Post
    I am new to microcontrollers. I am going to build my first project "Push button controlled PWM" using PIC12F675 for dimming LEDs.

    I want to control the duty cycle of 100Hz pulse from 0-100%.
    Two pushbuttons, one for increment and another for decrement of duty cycle.
    Resolution required is in steps of 2%.

    Kindly help me with code.

    Don't have knowledge and experience of programming.

    Thx.
    ashwal.patel@gmail.com
    Why have you decided to use a 12F675. What was your selection criteria for this chip?
    stellascapes - LED lighting solutions for the Prosumer, Commercial and Entertainment Industries.
    Doing pixels first since 2009 with just another megatree.
    Follow us on Facebook at www.facebook.com/stellascapes
    web: www.stellascapes.com

  6. #6
    Join Date
    Dec 2007
    Location
    Canberra, ACT, Australia
    Posts
    600

    Default Re: Push botton dimmer

    Considering this appears to be posted across multiple forums it's nothing more than an assignment.
    forum.allaboutcircuits.com/showthread.php?t=24126
    http://www.microchip.com/forums/tm.a...1&key=&#426681

    Mods what do you think?
    2012:
    Software: LightFactory Personal
    Hardware: J1Sys Pixel controllers . Http://www.j1sys.com
    Lights: 6000+ Pixels and 20k+ LEDs
    Channels: around 20,000 channels

    You know where to find me....

  7. #7

  8. #8

    Default Re: Push botton dimmer

    Hello everyone! I'm doing this as a personal project but I need some assistance. I had to do some reading and research of my own before asking any questions because many terms weren't clear to me. After my study, I wrote this code:

    [syntax=c]/* PROGRAM WRITTEN BY TAIWO FOLU. PWM CONTROL OVER BLUETOOTH WITH DTMF TONES. INPUT ON ATTINY2313 PINS PB4 TO PB7. PWM SIGNAL OUTPUT ON PB2 (OC0A) AND PD5 (OC0B) USING TIMER0. TWO EXTRA I/O PINS ON PB0 AND PB1*/

    #include <avr/io.h>
    void initPWM()
    {
    TCCR0|=(1<<WGM01)|(1<<COM01)|(1<<CS00);
    //Freq=FCPU, phase correct pwm, non inverted PWM (mode3)
    DDRB|=0xE0; //Set PB0, PB1 and PB2 for output and the rest for input
    DDRD|=(1<<PD5); //Set PD5 for output
    }
    void SetPWMOutput(Uint8_t duty)
    {
    OCR0A=0; //Set dutyA to 0%
    OCR0B=127; //Set dutyB to 50%
    }
    void main()
    {
    Unsinged int f;
    while (1)
    {
    f=PINB;
    switch (f)
    {
    case 0x04: //when key 4 is pressed
    {
    OCR0B++; //increment OCR0B
    break;
    }
    case 0x05: //when key 5 is pressed
    {
    OCR0A++; //increment OCR0A
    break;
    }
    case 0x06: //when key 6 is pressed
    {
    OCRB--; //decrement OCR0B
    break;
    }
    case 0x0A: //when key0 is pressed
    {
    OCR0A--; //decrement OCR0A
    break;
    }
    }
    }[/syntax]



    I intend to use the dtmf tones to control the duty cycles of pwm channels A and B on timer0. Please look through the code and help me if i've made any mistakes or unnecessary statements or he there's a better way to implement this. Here, i've not used the PB0 and PB1 pins yet so I don't get confused, I want to get the duty cycles control right first.

    Cheers
    Last edited by taiwofolu; 04-10-2012 at 07:47 AM.

  9. #9

    Default Re: Push botton dimmer

    Another "assignment"

  10. #10

    Default Re: Push botton dimmer

    lol! Really, its not. I read all this stuff on my own:

    http://scrapheli.blogspot.com


    https://picasaweb.google.com/taiwofolu?feat=email

    i'm not in school yet. Any help?
    Last edited by taiwofolu; 04-10-2012 at 02:28 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •