Hi all
I am using the 16f877a, I set the port A as the input and PortB as the output,
in "c" 'how to scan when any of the portA buttons are pressed
please give some Idea, I want to control the PortB by the portA
thanks
Saran
how to read the input ports
-
- Posts: 61
- Joined: Thu Dec 20, 2007 4:23 pm
- Location: singapore
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: how to read the input ports
hello Saran
Essentially you can just read porta into a variable by doing the following.
Then you can create a loop like this to detect when porta changes its value.
Testing a single bit or switch can can be done as follows.
Essentially you can just read porta into a variable by doing the following.
Code: Select all
char input;
input = porta;
Code: Select all
char oldinput;
oldinput = input
while (oldinput == input)
{
input = porta;
}
Code: Select all
if (test_bit(porta, 0))
{
//RA0 Set
}
else
{
//RA0 Clear
}
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel