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
}