PWM LED Chaser Programming with PIC Microcontroller – electroSome https://electrosome.com/topic/pwm-led-chaser-pic/feed/ Sat, 18 Mar 2023 05:01:16 +0000 https://bbpress.org/?v=2.6.9 en-US https://electrosome.com/topic/pwm-led-chaser-pic/#post-11542 <![CDATA[PWM LED Chaser Programming with PIC Microcontroller]]> https://electrosome.com/topic/pwm-led-chaser-pic/#post-11542 Sat, 04 Jul 2015 03:22:45 +0000 manjula 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
}
]]>
https://electrosome.com/topic/pwm-led-chaser-pic/#post-11546 <![CDATA[Reply To: PWM LED Chaser Programming with PIC Microcontroller]]> https://electrosome.com/topic/pwm-led-chaser-pic/#post-11546 Sat, 04 Jul 2015 10:20:46 +0000 Ligo George 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.

]]>