switch S.O.S.

Status
Not open for further replies.

butters

Member
Code:
if(PORTBbits.RB0 == 1)
{

//	while(!PORTBbits.RB0);
//PORTBbits.RB2 =~ PORTBbits.RB2;

while (BusyUSART());
//value sent
putcUSART(0xCE);//c

while (BusyUSART());
//value sent
putcUSART(0x01); //c1

while (BusyUSART());
//value sent
putcUSART(0x42);//c2

while (BusyUSART());
//value sent
putcUSART(0x03);//c3

while (BusyUSART());
//value sent
putcUSART(0xB9);//c4
}

if(PORTAbits.RA4 == 1)
{

//while(!PORTAbits.RA4);
//PORTBbits.RB3 =~ PORTBbits.RB3;

while (BusyUSART());
//value sent
putcUSART(0xCE);//c

while (BusyUSART());
//value sent
putcUSART(0x01); //c1

while (BusyUSART());
//value sent
putcUSART(0x44);//c2

while (BusyUSART());
//value sent
putcUSART(0x03);//c3

while (BusyUSART());
//value sent
putcUSART(0xB7);//c4
}

hi there... i hv implemented switches for this code.. if rb0 is pressed, the 1st set of msg is to be send.. if ra4 is pressed, the 2nd set of msg is to be send... the problem now is that i cant send both of them.. when i presssed, no byte comes out...

is it becoz of my conditions?

Noggin

Member
How are your tris registers set?

change while(!PORTAbits.RA4); to while(PORTAbits.RA4 == 1); and uncomment it. Do the same for the other one. What you want the code to do is wait while the button is 1. This also assumes that if you release the button the input is 0 and when you press it the input is 1. Can you show a schematic? Do you have a pulldown on the input?

Status
Not open for further replies.

Replies
7
Views
802
Replies
33
Views
3K
Replies
4
Views
2K
Replies
13
Views
9K
Replies
1
Views
779