- This topic has 2 replies, 3 voices, and was last updated 10 years, 3 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
|
Microcontroller › 8051 › Serial communcation using 8051
Sir I am using a switch on P2.0. when switch off A is transmit infinite times and whent it is off B is transmit infinite times but i want to transmit only one time,what changes i will do in code.
Hi,
did you mean “P2.0. when switch ON A is transmit infinite times and whent it is OFF B is transmit infinite times”.
You have written “off” only !!
What you can do is once an ON condition is detected send A and wait till the condition becomes OFF, and once it is OFF send B and wait till the ON condition is detected. Repeat this in a loop.
The following code is just to give you an idea;
while ( 1 )
{
while (OFF); // wait till ON is detected, the condition fails and go to next statement
sendA ();
while (ON); // wait till OFF is detected, the condition fails and go to next statement
sendB ();
}
you have to give key debounce delay after key is pressed. then send A once and enter in continuous loop that will send B only once and do nothing till key is pressed again