CodePudding user response:
This is the first time cycle code# include & lt; IoCC2530. H>
Typedef unsigned char uchar;
Typedef unsigned int uint;
# define D3 P1_0
# define D4 P1_1
# define D5 P1_3
# define D6 P1_4
# define SW1 P1_2
# define ON 0
# define OFF 1
Void DelayMS (without msec)
{
Without the I, j;
for(i=0; i
}
Void LedONorOFF (uchar mode)
{
D3=mode;
D4=mode;
D5=mode;
D6=mode;
}
Void InitLed (void)
{
P1DIR |=0x1B;
LedONorOFF (mode: 0);
}
Void InitKey (void)
{
P1SEL & amp;=~ 0 x04;
P1DIR & amp;=~ 0 x04;
P1INP & amp;=~ 0 x04;
}
Uchar KeyScan (void)
{
If (SW1==0)
{
DelayMS (msec: 10);
If (SW1==0)
{
while(! SW1);
return 1;
}
}
return 0;
}
Void main (void)
{
InitLed ();
InitKey ();
While (1)
{
DelayMS (msec: 2);
If (Keyscan ())
{
D4=ON;
DelayMS (msec: 1000);
D4=OFF;
D3=ON;
DelayMS (msec: 1000);
D3=OFF;
D6=ON;
DelayMS (msec: 1000);
D6=OFF;
D5=ON;
DelayMS (msec: 1000);
D5=OFF;
}
}
}