| ??? 01/29/03 19:36 Read: times |
#37684 - switches on port 2 of 89C51 |
Hi.
I have a system where there are 8 switches on port 2. To detect the switches, I have connected them to ground. When a switch is pressed that pin goes low. I need a routine where one press only changes the values once. This routine works, but only for P2.0 to P2.3. For some reason it doesnt work for P2.4 to P2.7. Can anyone help? void wait_switch(char a){ char i=0; do{ i=~P2; i=i>>a; }while ((i^0x00)==1); } void main(void){ wait_switch(7); } The syntax to call the routine is wait_switch(i) where i is the pin where the zero is detected (ie the switch that is pressed). I am using Raisonance. Thanks! Adam Morris |
| Topic | Author | Date |
| switches on port 2 of 89C51 | 01/01/70 00:00 | |
| RE: switches on port 2 of 89C51 | 01/01/70 00:00 | |
| RE: switches on port 2 of 89C51 | 01/01/70 00:00 | |
| RE: switches on port 2 of 89C51 | 01/01/70 00:00 | |
| RE: switches on port 2 of 89C51 | 01/01/70 00:00 | |
| RE: switches on port 2 of 89C51 | 01/01/70 00:00 | |
| RE: switches on port 2 of 89C51 | 01/01/70 00:00 | |
| RE: switches on port 2 of 89C51 | 01/01/70 00:00 | |
| RE: switches on port 2 of 89C51 | 01/01/70 00:00 | |
| RE: switches on port 2 of 89C51 | 01/01/70 00:00 | |
| RE: switches on port 2 of 89C51 | 01/01/70 00:00 | |
RE: switches on port 2 of 89C51 | 01/01/70 00:00 |



