Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I get lights to loop pattern Below is the lab I'm working on, I have everything working except the rotation, once it reaches

How do I get lights to loop pattern

Below is the lab I'm working on, I have everything working except the rotation, once it reaches the end of the line it stops, I need the light to loop infinitely: EX: (x light, 0 off) 0xxx000000 --> xxx0000000 --> xx0000000x excetera

Write a program in C that reads a 3-bit desired light pattern from the 3 input switches connected to pins P2.3-P2.5 and displays the patter on the 8 LEDs with some rotation options based on the other 3 switches.

[4] 3.a) Switch on Port2.0 (Read/Rotate mode)

On (logic 0) Read mode: Your program continuously reads the switches and takes only the 3-bits (Port 2.3-2.5) as a desired display pattern and displays them 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.

[4] 3.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.

[4] 3.c) Switch on Port2.2 (Fast/Slow speed mode) **Hint: Software Delay**

On (logic 0) The patter rotation is Fast.

Off (logic 1) The patter rotation is Slow.

This is what i have so far::

#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) { // read all switches and save them in R5_SW R5_SW = P2IN; // check for read mode if (R5_SW & BIT0) { R6_LED = R5_SW & (BIT3 | BIT4 | BIT5); // copy the pattern from the switches and mask P1OUT = R6_LED; // send the pattern out } // display rotation mode else { // check for direction if (R5_SW & BIT1) {R6_LED <<= 1; } // rotate left else {R6_LED >>=1; } // rotate right // mask any excessive bits of the pattern and send it out R6_LED &= 0xFF; // help clear all bits beyound the byte so when you rotate you do not see garbage coming in P1OUT = R6_LED;

// check for speed if (R5_SW & BIT2) {__delay_cycles( 40000); } //fast else {__delay_cycles(100000); } //slow } } }

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago