Question: 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

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 Databases Questions!