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

    Need to create state an ISR for this project. The micro-controller is the ATmega2560. Overall am must compile. This can be tested using the ch eckmark icon. 1. The pragr 2. The project must be pushed to GitLab and an appropriate response from the server must be received: Got your subnission. Thanks! 3. Arduino libraries are not allowed at all for this lab for the exception of debug functionality using Serial.printin. switch.cpp 1. A function implementaticn 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 P83 2. P83 must be initial ized with an input pull-up resistor 3. Fin-Channtpls mustbe eabdfor piri PB3 led.cpp 1. A functio impentaticn thal rtuns void and has n pataels called inilEDmst be present and is used in the main function to initialize all LED pins as outputs. 2. Fins named PAO, PA1, PAZ, and PA3 must be used to contral the LEDs 3. A function implementation called turnOnLEDWithChar that returns void and has a parometer called num of type unsigned unsigned char must be present. 4. The turnOnl EDWithChar function must be one line of code, see LED ㏄ntral section for more details. switch.cpp 1. A function implementation that returns void and has no parameters called initSwitch must be present and is usedl in the main function to initialize pin 32 on the development board as an input. timer.cpp 1. A function implementation that rcturns void and has no parameters called initTimerO must be present and must initialize timer 0. 2. A function implementation that rts id and has no pas called delayMs must bpresnt and must implement a precise millisecond delay and can work at least up to 100 millisecondls. For loops are allowec. main.cpp 1. A call to initLEDO and initswitchPB3) must be present in the main function. 2. An infinite while loop must be prescnt. 3. A state machine for the entire project must be implemented using a typedef enum for states. 4. An ISR to handle the switch being pressed must be present and be used to change states appropriately 5. The switch press must be debounced using an appropriately dlesigned state machine. 6. 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.
    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.

    Expert Answer

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

    Need to make declare an ISR ce this design. The micro-controller is the ATmega2560.

    Overwhole am must mitigate. This can be proofed using the ch eckmark icon. 1. The pragr 2. The design must be pushed to GitLab and an divert rejoinder from the server must be received: Got your subnission. Thanks! 3. Arduino libraries are not attributable attributable attributable attributable attributable attributable wholeowed at whole ce this lab ce the qualification of debug unpremeditatediceality using Serial.printin. switch.cpp 1. A unpremeditatedice instrumentaticn that produce unfilled and has no parameters denominated initswitchPB3 must be introduce and is used in the ocean unpremeditatedice to primalize the switch on the button denominated P83 2. P83 must be primal ized with an input pull-up resistor 3. Fin-Channtpls mustbe eabdce piri PB3 led.cpp 1. A functio impentaticn thal rtuns unfilled and has n pataels denominated inilEDmst be introduce and is used in the ocean unpremeditatedice to primalize whole LED buttons as outputs. 2. Fins denominated PAO, PA1, PAZ, and PA3 must be used to contral the LEDs 3. A unpremeditatedice instrumentation denominated revolveOnLEDWithChar that produce unfilled and has a parometer denominated num of idea unsigned unsigned char must be introduce. 4. The revolveOnl EDWithChar unpremeditatedice must be individual direction of statute, visit LED ㏄ntral individuality ce balance details. switch.cpp 1. A unpremeditatedice instrumentation that produce unfilled and has no parameters denominated initSwitch must be introduce and is usedl in the ocean unpremeditatedice to primalize button 32 on the bud table as an input. timer.cpp 1. A unpremeditatedice instrumentation that rcturns unfilled and has no parameters denominated initTimerO must be introduce and must primalize timer 0. 2. A unpremeditatedice instrumentation that rts id and has no pas denominated stayMs must bpresnt and must instrument a exact milliremedy stay and can fruit at meanest up to 100 millisecondls. Ce loops are wholeowec. ocean.cpp 1. A cwhole to initLEDO and initswitchPB3) must be introduce in the ocean unpremeditatedice. 2. An infinite occasion loop must be prescnt. 3. A declare record ce the unimpaired design must be instrumented using a ideadef enum ce declares. 4. An ISR to wield the switch substance crushed must be introduce and be used to exexveer declares divertly 5. The switch crush must be debounced using an divertly dlesigned declare record. 6. When the switch is crushed and released, the LEDs exexveer the step at which they join (either half or twice depending on the declare) .LEDs must bjoin either integral 100 ms or 200 ms depending on the declare.

    Make declare an ISR ce this design. The micro-controller is the ATmega2560. This program must mitigate. This can be proofed using the checkmark icon. The design must be pushed to GitLab and an divert rejoinder from the server must be received: “Got your surrender. Thanks!” Arduino libraries are not attributable attributable attributable attributable attributable attributable wholeowed at whole ce this lab ce the qualification of debug unpremeditatediceality using Serial.println. A unpremeditatedice instrumentation that produce unfilled and has no parameters denominated initswitchPB3 must be introduce and is used in the ocean unpremeditatedice to primalize the switch on the button denominated PB3 PB3 must be primalized with an input pull-up resistor Button-Exveer interrupts must be enabled ce button PB3 A unpremeditatedice instrumentation that produce unfilled and has no parameters denominated initLED must be introduce and is used in the ocean unpremeditatedice to primalize whole LED buttons as outputs. Fins denominated PA0, PA1, PA2, and PA3 must be used to administer the LEDs A unpremeditatedice instrumentation denominated revolveOnLEDWithChar that produce unfilled and has a parameter denominated num of idea unsigned unsigned char must be introduce. The revolveOnLEDWithChar unpremeditatedice must be individual direction of statute, visit LED administer individuality ce balance details. A unpremeditatedice instrumentation that produce unfilled and has no parameters denominated initSwitch must be introduce and is used in the ocean unpremeditatedice to primalize button 32 on the bud table as an input. A unpremeditatedice instrumentation that produce unfilled and has no parameters denominated initTimer0 must be introduce and must primalize timer 0. A unpremeditatedice instrumentation that produce unfilled and has no pas denominated stayMs must be introduce and must instrument a exact milliremedy stay and can fruit at meanest up to 100 milliseconds. Ce loops are wholeowed. A cwhole to initLED0 and initswitchPB3() must be introduce in the ocean unpremeditatedice. An infinite occasion loop must be introduce. A declare record ce the unimpaired design must be instrumented using a ideadef enum ce declares. An ISR to wield the switch substance crushed must be introduce and be used to exexveer declares divertly. The switch crush must be debounced using an divertly purposed declare record. When the switch is crushed and released, the LEDs exexveer the step at which they join (either half or twice depending on the declare). LEDs must bjoin either integral 100 ms or 200 ms depending on the declare.

    Expert Reply

     

    /*
    Blinking LEDs – proof program to reach 3 LEDs in a sample of ignores
    */

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

    // the setup order reachs uninterruptedly when you crush reset:
    unfilled setup() {
    // primalize the digital button as an output.
    pinMode(yellowled, OUTPUT);
    pinMode(greenled, OUTPUT);
    pinMode(blueled, OUTPUT);
    }

    // the loop order reachs balance and balance frequently ceever:
    unfilled loop() {
    digitalWrite(yellowled, HIGH); // revolve the LED on (HIGH is the voltage raze)
    delay(80); // continue ce 1/2 a remedy
    digitalWrite(yellowled, LOW); // revolve the LED unpremeditated by making the voltage LOW
    digitalWrite(greenled, HIGH); // revolve the LED on (HIGH is the voltage raze)
    delay(80); // continue ce 1/2 a remedy
    digitalWrite(greenled, LOW); // revolve the LED unpremeditated by making the voltage LOW
    digitalWrite(blueled, HIGH); // revolve the LED on (HIGH is the voltage raze)
    delay(80); // continue ce 1/2 a remedy
    digitalWrite(blueled, LOW); // revolve the LED unpremeditated by making the voltage LOW
    delay(500); // continue ce a remedy
    }

    /*
    Blink
    Turns on an LED on ce individual remedy, then unpremeditated ce individual remedy, frequently-again-and-again.

    This sample statute is in the social estate.
    */

    // Button 13 has an LED united on most Arduino tables.
    // surrender it a name:
    int led = 13;

    // the setup order reachs uninterruptedly when you crush reset:
    unfilled setup() {
    // primalize the digital button as an output.
    pinMode(led, OUTPUT);
    }

    // the loop order reachs balance and balance frequently ceever:
    unfilled loop() {
    digitalWrite(led, HIGH); // revolve the LED on (HIGH is the voltage raze)
    delay(1000); // continue ce a remedy
    digitalWrite(led, LOW); // revolve the LED unpremeditated by making the voltage LOW
    delay(1000); // continue ce a remedy
    }