Continue to Site

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.

Detecting PORTA Buttons

Status
Not open for further replies.

Suraj143

Active Member
Hi all!

RA4, RA5, RA6 is my input buttons they are active LOW inputs.

In my earlier post guys suggested me to detect/read the whole PORTA using this command.

Code:
	movf	PORTA,W

This method is good when inputs coming from a digital IC. But when I giving inputs from switches the above command not working. So I have to check all three buttons individually.

Is there any method to detect two or three buttons at a time? It means

*when I press RA4 & RA5 both only the output LED1 lights up.
*When I press RA4, RA5, RA6 only the output LED2 lights up.

Thanks
 
Suraj143 said:
Hi all!

RA4, RA5, RA6 is my input buttons they are active LOW inputs.

In my earlier post guys suggested me to detect/read the whole PORTA using this command.

Code:
	movf	PORTA,W

This method is good when inputs coming from a digital IC. But when I giving inputs from switches the above command not working. So I have to check all three buttons individually.

Is there any method to detect two or three buttons at a time? It means

*when I press RA4 & RA5 both only the output LED1 lights up.
*When I press RA4, RA5, RA6 only the output LED2 lights up.

Thanks
This sounds the same as your previous post.
I think I know why yours wasn't working. You're using active low input, so instead of
xorlw b'01110000' (this is for active high input)
try
xorlw 0x00
and of course, don't forget to take only bit 4 to 6 by AND function before XOR. Try it.
 
Wow Bnanasiong you are great it realy worked well after changing values to XORLW 0X00.

Actually I missed that Logic.Now everything is OK & works fine.
Now its easy to read a PORT in any manner.

Thanks a lot Bananasiong
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top