Lighting leds on matrix multimedia board
Posted: Wed Aug 23, 2006 9:36 pm
The following code does not work, it is supposed to be lighitng leds on porta, as the port b buttons are pressed.
Please check it and let me know. PIC 16f876 matrix multimedia version2 board. Is there any other way to make it work. thank you ukweb
Code: Select all
#include <system.h>
main()
{
while(1)
{
int count=0;
set_bit(STATUS, RP0); //SELECTS BANK 1
TRISA=0x00; //MAKES PORTA outPUT
TRISB=0xff; //MAKES PORTB inPUT
clear_bit(STATUS, RP0); //SELECTS BANK 0
adcon1=0x07;
if(input_pin_port_b(7))
{
count=count+1;
}
else if(input_pin_port_b(6))
{
count=count-1;
}
if(count==1)
{
output_high_port_a(0);
}else
{
output_low_port_a(0);
}
if(count==2)
{
output_high_port_a(1);
}else
{
output_low_port_a(1);
}
if(count==3)
{
output_high_port_a(2);
}else
{
output_low_port_a(2);
}
}
}