PWM LED Chaser Programming with PIC Microcontroller

Home Forums Microcontrollers PIC Microcontroller PWM LED Chaser Programming with PIC Microcontroller

Tagged: , , ,

This topic contains 1 reply, has 2 voices, and was last updated by  Ligo George 1 year, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #11542

    manjula
    Participant

    I would like to make a PWM LED light system, with PORTA & PORTB of 16F628A.
    I want to shift to A+B Port with pwm night rider shadow LED program

    void main()
    {
      CMCON = 0x07; // To turn off comparators
      ADCON1 =0x06; //Turne off adc
      TRISB = 0x00; // Sets all pins in PORTB as output
      PORTB = 0b00000001; // Set RB0 to high 00000001
      TRISA = 0x00; // Sets all pins in PORTB as output
      PORTA = 0b00000000; // Set RB0 to high 00000001
    
      do // To set infinite loop
      {
        Delay_ms(100); // 300 mili seconds delay
        PORTA = PORTA<<1; //Shifting right by one bit
        if(PORTA >= 0b10000000) //To reset to 00000001
        {                          //when the count becomes 10000000
          Delay_ms(100);
          PORTA = 0b00000000
          PORTB = 0b00000001
        }
        if(PORTB >= 0b00000001) //If RB7 =1
        {
          Delay_ms(100);
          PORTB = PORTB<<1; //Shift one bit right
          if(PORTB >= 0b10000000) //To reset to 00000001
          {
            Delay_ms(100); //
            PORTB =0b00000000; //RB low
            PORTA =0b00000001;
          }
        }
      }while(1); // To set infinite loop
    }
    #11546

    Ligo George
    Keymaster

    You can’t do it by simple shifting. I think you need a scanning algorithm for that. You can scan ( making it ON, depending on the required brightness ) each LED one by one fastly ( faster than our eyes can recognize ).

    I hope that you can use the built in PWM module for that.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.