Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
convert the following c + + code to AVR Assembly code: #include #include #include / / Pin Definitions #define START _ PAUSE _ BUTTON 1
convert the following c code to AVR Assembly code: #include #include #include Pin Definitions #define STARTPAUSEBUTTON #define STOPBUTTON #define RGBREDPIN #define RGBGREENPIN #define RGBBLUEPIN A const int ledPins; const int numLeds ; const int numRounds ; const int ledOnTime ; Milliseconds each LED is on int currentLED ; int score ; int currentRound ; int indicatorLED; bool gameRunning false; bool pauseGame false; int lastStartPauseButtonState HIGH; int lastStopButtonState HIGH; void setup Serial.begin; for int i ; i numLeds; i pinModeledPinsi OUTPUT; pinModeSTARTPAUSEBUTTON, INPUTPULLUP; pinModeSTOPBUTTON, INPUTPULLUP; pinModeRGBREDPIN, OUTPUT; pinModeRGBGREENPIN, OUTPUT; pinModeRGBBLUEPIN, OUTPUT; void loop int startButtonState digitalReadSTARTPAUSEBUTTON; int stopButtonState digitalReadSTOPBUTTON; Serial.printStart button state: ; Serial.printlnstartButtonState; Serial.printStop button state: ; Serial.printlnstopButtonState; StartPause the game if startButtonState LOW && lastStartPauseButtonState HIGH delay; Debouncing if digitalReadSTARTPAUSEBUTTON LOW Check if still pressed if gameRunning gameRunning true; currentRound ; score ; Serial.printlnGame Started"; pickIndicatorLED; else pauseGame pauseGame; Serial.printlnpauseGame "Game Paused" : "Game Resumed"; lastStartPauseButtonState startButtonState; Stop button logic if stopButtonState LOW && lastStopButtonState HIGH delay; Debouncing if digitalReadSTOPBUTTON LOW Check if still pressed if gameRunning && currentLED indicatorLED score; Serial.printScore: ; Serial.printlnscore; currentRound; if currentRound numRounds pickIndicatorLED; else gameRunning false; updateRGBscore; Serial.printlnGame Over"; lastStopButtonState stopButtonState; Game logic when running and not paused if gameRunning && pauseGame cycleLEDs; void pickIndicatorLED indicatorLED random numLeds; Serial.printIndicator LED: ; Serial.printlnindicatorLED; void cycleLEDs for int i ; i numLeds; i digitalWriteledPinsi HIGH; delayledOnTime; digitalWriteledPinsi LOW; currentLED i; void updateRGBint score digitalWriteRGBREDPIN, LOW; digitalWriteRGBGREENPIN, LOW; digitalWriteRGBBLUEPIN, LOW; if score digitalWriteRGBGREENPIN, HIGH; else if score digitalWriteRGBBLUEPIN, HIGH; else digitalWriteRGBREDPIN, HIGH;
convert the following c code to AVR Assembly code:
#include
#include
#include
Pin Definitions
#define STARTPAUSEBUTTON
#define STOPBUTTON
#define RGBREDPIN
#define RGBGREENPIN
#define RGBBLUEPIN A
const int ledPins;
const int numLeds ;
const int numRounds ;
const int ledOnTime ; Milliseconds each LED is on
int currentLED ;
int score ;
int currentRound ;
int indicatorLED;
bool gameRunning false;
bool pauseGame false;
int lastStartPauseButtonState HIGH;
int lastStopButtonState HIGH;
void setup
Serial.begin;
for int i ; i numLeds; i
pinModeledPinsi OUTPUT;
pinModeSTARTPAUSEBUTTON, INPUTPULLUP;
pinModeSTOPBUTTON, INPUTPULLUP;
pinModeRGBREDPIN, OUTPUT;
pinModeRGBGREENPIN, OUTPUT;
pinModeRGBBLUEPIN, OUTPUT;
void loop
int startButtonState digitalReadSTARTPAUSEBUTTON;
int stopButtonState digitalReadSTOPBUTTON;
Serial.printStart button state: ;
Serial.printlnstartButtonState;
Serial.printStop button state: ;
Serial.printlnstopButtonState;
StartPause the game
if startButtonState LOW && lastStartPauseButtonState HIGH
delay; Debouncing
if digitalReadSTARTPAUSEBUTTON LOW Check if still pressed
if gameRunning
gameRunning true;
currentRound ;
score ;
Serial.printlnGame Started";
pickIndicatorLED;
else
pauseGame pauseGame;
Serial.printlnpauseGame "Game Paused" : "Game Resumed";
lastStartPauseButtonState startButtonState;
Stop button logic
if stopButtonState LOW && lastStopButtonState HIGH
delay; Debouncing
if digitalReadSTOPBUTTON LOW Check if still pressed
if gameRunning && currentLED indicatorLED
score;
Serial.printScore: ;
Serial.printlnscore;
currentRound;
if currentRound numRounds
pickIndicatorLED;
else
gameRunning false;
updateRGBscore;
Serial.printlnGame Over";
lastStopButtonState stopButtonState;
Game logic when running and not paused
if gameRunning && pauseGame
cycleLEDs;
void pickIndicatorLED
indicatorLED random numLeds;
Serial.printIndicator LED: ;
Serial.printlnindicatorLED;
void cycleLEDs
for int i ; i numLeds; i
digitalWriteledPinsi HIGH;
delayledOnTime;
digitalWriteledPinsi LOW;
currentLED i;
void updateRGBint score
digitalWriteRGBREDPIN, LOW;
digitalWriteRGBGREENPIN, LOW;
digitalWriteRGBBLUEPIN, LOW;
if score
digitalWriteRGBGREENPIN, HIGH;
else if score
digitalWriteRGBBLUEPIN, HIGH;
else
digitalWriteRGBREDPIN, HIGH;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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