Hi ET,
I am doing my Microcontroller course for the first time and have few difficulties nin writing C program for PIC16F877Program must read upper 4 switches connected to PORTB(SB4-SB7)and activate corresponding lamp connected to lower part of PORTB(LB0-LB3, respectively). Also
-If switch SB7 is pressed, all four LB0-LB3 lamps should be ON as long as SB7 is pressed
-If switch SB6 is pressed, all four LB0-LB3 lamps should flash ON and OFFwith 1 sec delay as long as SB6 is pressed
I have written program but this is not working
Char count=0;
void main (void)
{
set_bit (STATUS,5);
set_bit (STATUS,6);
TRISB=0xF0;
set_bit (STATUS, 5);
if(COUNT>=0xF0)
PORTB=0x00
else PORTB=0x0F;
set_bit (STATUS,5);
clear_bit (STATUS,6);
while(1) {
{
PORTB=0x0F;
delay_ms(1000);
PORTB=0xF0;
delay_ms(1000);
}
}
Thanks
Raaj
I am doing my Microcontroller course for the first time and have few difficulties nin writing C program for PIC16F877Program must read upper 4 switches connected to PORTB(SB4-SB7)and activate corresponding lamp connected to lower part of PORTB(LB0-LB3, respectively). Also
-If switch SB7 is pressed, all four LB0-LB3 lamps should be ON as long as SB7 is pressed
-If switch SB6 is pressed, all four LB0-LB3 lamps should flash ON and OFFwith 1 sec delay as long as SB6 is pressed
I have written program but this is not working
Char count=0;
void main (void)
{
set_bit (STATUS,5);
set_bit (STATUS,6);
TRISB=0xF0;
set_bit (STATUS, 5);
if(COUNT>=0xF0)
PORTB=0x00
else PORTB=0x0F;
set_bit (STATUS,5);
clear_bit (STATUS,6);
while(1) {
{
PORTB=0x0F;
delay_ms(1000);
PORTB=0xF0;
delay_ms(1000);
}
}
Thanks
Raaj