Microcontroller › 8051 › Serial communcation using 8051 › Hi,did you mean “P2.0. when
August 24, 2014 at 6:28 am
#12065
Participant
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 ();
}