Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need to create state an ISR for this project. The micro-controller is the ATmega

ID: 3882160 • Letter: N

Question

Need to create state an ISR for this project. The micro-controller is the ATmega2560.

Create state an ISR for this project. The micro-controller is the ATmega2560. This program must compile. This can be tested using the checkmark icon. The project must be pushed to GitLab and an appropriate response from the server must be received: "Got your submission. Thanks!" Arduino libraries are not allowed at all for this lab for the exception of debug functionality using Serial.println. A function implementation that returns void and has no parameters called initswitchPB3 must be present and is used in the main function to initialize the switch on the pin named PB3 PB3 must be initialized with an input pull-up resistor Pin-Change interrupts must be enabled for pin PB3 A function implementation that returns void and has no parameters called initLED must be present and is used in the main function to initialize all LED pins as outputs. Fins named PA0, PA1, PA2, and PA3 must be used to control the LEDs A function implementation called turnOnLEDWithChar that returns void and has a parameter called num of type unsigned unsigned char must be present. The turnOnLEDWithChar function must be one line of code, see LED control section for more details. A function implementation that returns void and has no parameters called initSwitch must be present and is used in the main function to initialize pin 32 on the development board as an input. A function implementation that returns void and has no parameters called initTimer0 must be present and must initialize timer 0. A function implementation that returns void and has no pas called delayMs must be present and must implement a precise millisecond delay and can work at least up to 100 milliseconds. For loops are allowed. A call to initLED0 and initswitchPB3() must be present in the main function. An infinite while loop must be present. A state machine for the entire project must be implemented using a typedef enum for states. An ISR to handle the switch being pressed must be present and be used to change states appropriately. The switch press must be debounced using an appropriately designed state machine. When the switch is pressed and released, the LEDs change the pace at which they link (either half or twice depending on the state). LEDs must blink either every 100 ms or 200 ms depending on the state.

Explanation / Answer

/*
Blinking LEDs - test program to run 3 LEDs in a pattern of blinks
*/

int yellowled = 12;
int greenled = 10;
int blueled = 7;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(yellowled, OUTPUT);   
pinMode(greenled, OUTPUT);
pinMode(blueled, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(yellowled, HIGH); // turn the LED on (HIGH is the voltage level)
delay(80); // wait for 1/2 a second
digitalWrite(yellowled, LOW); // turn the LED off by making the voltage LOW
digitalWrite(greenled, HIGH); // turn the LED on (HIGH is the voltage level)
delay(80); // wait for 1/2 a second
digitalWrite(greenled, LOW); // turn the LED off by making the voltage LOW
digitalWrite(blueled, HIGH); // turn the LED on (HIGH is the voltage level)
delay(80); // wait for 1/2 a second
digitalWrite(blueled, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}

/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.

This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);   
}

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote