Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ATmega4809 The following code turns ON one LED at a time, and shifts that left and right. Modify the program such that the program turns

ATmega4809

The following code turns ON one LED at a time, and shifts that left and right. Modify the program such that the program turns OFF one LED at a time, and shifts it left and right.

#include #define F_CPU 3333333 #include

#define DELAY_COUNT 6 /* For simulation purposes we use a short count: for a real chip we would need a much longer delay */

int main(void) { uint8_t i = 0; /* Use i as the shift value in the loops below */ PORTA.DIR = 0b11111111; /- set all the bits of PORTA.DIR to 1: all PORT bits will be outputs */ while (1) { for (i = 1; i < 128; i = i*2) { PORTA.OUT = i ; /* PORTA.OUT will go through 1, 2, 4 etc */ _delay_loop_2(DELAY_COUNT); } for (i = 128; i > 1; i = i/2) { PORTA.OUT = i; /* PORTA.OUT will go through 128, 64, 32 etc */ _delay_loop_2(DELAY_COUNT); } } }

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

More Books

Students also viewed these Databases questions

Question

Identify the four methods used to calcu- late education funding.

Answered: 1 week ago

Question

Give three examples of access control in a POS system.

Answered: 1 week ago

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago

Question

e. What do you know about your ethnic background?

Answered: 1 week ago