Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Build the Code for MSP430G2553 Six LEDs: two red, two yellow and two red. No but

ID: 3711761 • Letter: B

Question

Build the Code for MSP430G2553

Six LEDs: two red, two yellow and two red. No buttons required.   Timer periodic interrupt.

Traffic Light

North/South LED East / West LED Delay

Red                                                         Green 5 seconds

Red                                                         Yellow 1 seconds

Red                                                         Red                                         1 seconds

Green Red 5 seconds

Yellow Red 1 seconds

Red                                                         Red 1 seconds

Repeat for ever

Explanation / Answer

The code for the Traffic light in MSP430G2553

#include <msp430g2553.h>

#define RLED BIT0
#define RLED1 BIT1
#define RLED2 BIT2
#define GLED BIT4
#define YLED BIT5
#define BLED3 BIT6

void main(void)
{
   WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
   // Init Clock Module
        if (CALBC1_1MHZ != 0xFF)
        {
            DCOCTL = 0x00;
            BCSCTL1 = CALBC1_1MHZ;       // Calibrate clock at 1MHz
            DCOCTL = CALDCO_1MHZ;
        }

   P1DIR |= RLED + RLED1 + RLED2 + GLED + YLED +RLED3; // Assign as output
   P1OUT = RLED + RLED1 + RLED2 + GLED + YLED +RLED3; //Turns on all LEDs
   P1OUT &= ~(RLED + RLED1 + YLED + RLED3 ); // Let only BLED and RLED2 on

   while(1)
   {

        P1OUT |= GLED;
        __delay_cycles(1000000);
        P1OUT |= RLED2;
        P1OUT &= ~RLED;
        __delay_cycles(6000000);

        P1OUT |= RLED1;
        P1OUT &= ~(RLED2);
        _delay_cycles(2000000);

        P1OUT &= ~(RLED1);
        P1OUT |= RLED;
        __delay_cycles(1000000);
        P1OUT |= RLED3;
        P1OUT &= ~GLED;
        __delay_cycles(6000000);

        P1OUT |= YLED;
        P1OUT &= ~RLED3;
        __delay_cycles(2000000);

        P1OUT &= ~YLED;
        __delay_cycles(200000);


   }
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote