I'm using the pic 18F4550 with microchip v8.63 and with the C compiler C18.
I want to trigger port RB3, RB4 and RB5. when, I press on respectively S1 (switch 1), S2 switch (S2) and S3 (switch 3). on these ports (RB3, RB4 and RB5) there are leds connected to, the should burn when I press S1 or S2 or S2.
My first question is, How do I stream from my S1 and S2 and S3 to the gates (RB3, RB4, RB5).
And second how can I enable port RB6, there is a light dependent resistor connected to.
I wrote this program: but, nothing is happening. only led 1 goes on.
#include "p18cxxx.h"
void main(void)
{
// turn off all LED latches
LATDbits.LATD0 = 0;
LATDbits.LATD1 = 0;
LATDbits.LATD2 = 0;
LATDbits.LATD3 = 0;
// make port d bits which drive LEDs outputs
TRISDbits.TRISD0 = 0;
TRISDbits.TRISD1 = 0;
TRISDbits.TRISD2 = 0;
TRISDbits.TRISD3 = 0;
if(PORTBbits.RB3 == 0) {
LATDbits.LATD0 = 1;
}
if(PORTBbits.RB4 == 0) {
LATDbits.LATD1 = 1;
}
if(PORTBbits.RB5 == 0) {
LATDbits.LATD2 = 1;
}
}