Question: Explain What the following code does. #include #define LED 1 ( 0 x 0 1 ) #define LED 2 ( 0 x 0 1 )

Explain What the following code does.
#include
#define LED1(0x01)
#define LED2(0x01)
#define S1(0x04)
#define S2(0x40)
void main(void)
{
volatile int OUT1[]={LED1, ~LED1, LED1, ~LED1, ~LED1, LED1, LED1, ~LED1};
volatile int OUT2[]={~LED2, LED2, LED2, ~LED2, LED2, LED2, ~LED2, LED1,};
volatile int TIME[]={40,10,50,20,50,15,30,15};
PM5CTL0 &= ~LOCKLPM5;
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= LED1;
P1OUT &= ~ LED1;
P4DIR |= LED2;
P4OUT &= ~ LED2;
P1DIR &= ~S1;
P1REN |= S1;
P1OUT |= S1;
P2DIR &= ~S2;
P2REN |= S2;
P2OUT |= S2;
volatile unsigned int i;
volatile unsigned int j;
volatile unsigned int k;
for (;;)
{
P1OUT &= ~LED1;
P4OUT &= ~LED2;
if(!(S1 & P1IN))
{
while (S2 & P2IN)
{
for(i=0; i<8; i++)
{
if (OUT1[i]== LED1)
P1OUT |= OUT1[i];
else if (OUT1[i]== ~LED1)
P1OUT &= OUT1[i];
if (OUT2[i]== LED2)
P4OUT |= OUT2[i];
else if (OUT2[i]== ~LED2)
P4OUT &= OUT2[i];
for(j=0; j

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!