Home › Forums › Microcontrollers › PIC Microcontroller › PWM LED Chaser Programming with PIC Microcontroller
- This topic has 1 reply, 2 voices, and was last updated 7 years, 8 months ago by Ligo George.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
July 4, 2015 at 8:52 am #11542manjulaParticipant
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 programvoid 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 }
July 4, 2015 at 3:50 pm #11546Ligo GeorgeKeymasterYou 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.
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.