Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

Latest threads

EE World Online Articles

Loading
Top