Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in Cthat reads a 3-bit desired light patternfromthe 3 input switches connected to pinsP2.3-P2.5and displays the patternon the 8 LEDs (pins P1.0-P1.7)

Write a program in Cthat reads a 3-bit desired light patternfromthe 3 input switches connected to pinsP2.3-P2.5and displays the patternon the 8 LEDs (pins P1.0-P1.7) with some light playing options based on the input from other 3 switches(pins P2.0-P2.2).

[8] 4.a)Switch on Port2.0 (Read/Rotatemode)?On(logic 0)Readmode: Your program continuously reads the switches and takes only the 3-bits (Port 2.3-2.5) as a desired display pattern and displaysthem on the LEDs (Port 1.3-1.5). All other LEDs on Port 1 are masked to zero (turned off). ?Off(logic 1) Rotate mode: Once this switch is turned off, your program will rotate the pattern on the 8 LEDs connected to Port1 pins 0-7. The pattern is the 3-bit value you constantly updated and saved during the Read mode.

[6] 4.b)Switch on Port2.1 (Left/Right direction mode) ?On (logic 0) The LED pattern rotates to the Left.?Off (logic 1) The LED pattern rotates to the Right.

[6] 4.c)Switch on Port2.2 (Fast/Slow speed mode) **Hint: Software Delay**?On (logic 0) The patternrotation is Fast.?Off (logic 1) The patternrotation is Slow.

[2] 4.d

Modify the program

so that the two Switches on Port2.0-1 provide four different

fun patterns which continuously display/move on the 8 LEDs. Keep Switch on Post 2.2 to

change speed

some of the code that was written

#include

int main(void) {

WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

int R5_SW=0, R6_LED=0, temp=0;

P1OUT = 0b00000000; // mov.b #00000000b,&P1OUT

P1DIR = 0b11111111; // mov.b #11111111b,&P1DIR

P2DIR = 0b00000000; // mov.b #00000000b,&P2DIR

while (1)

{

R5_SW = P2IN; //mov.b &P2IN, R5

if (R5_SW & BIT0) //checking P2.0 for read mode

{

R6_LED = R5_SW & (BIT3 | BIT4 | BIT5);

P1OUT = R6_LED;

}

else // display rotation mode

{

//you need to modify the toggle line below with pattern

rotation based on the value of P2.1

R6_LED ^= 0xFF;

//toggle pattern

R6_LED &= 0xFF;

//mask any excessive bits

P1OUT = R6_LED;

//pattern out - display it

//you need to replace the simple delay line below with

slow/fast delay based on P2.2

__delay_cycles( 400000);

//fast

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

Determine miller indices of plane X z 2/3 90% a/3

Answered: 1 week ago