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 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started