tivaC

3 games with single-player and multiplayer modes: Whac-A-Mole, Star Trek and Dec/Bin Converter

  • Used C on Tiva C Microcontroller and Orbit Booster Pack
  • Shout out to my teammates Bohan Shi and Zhaowei Wu

Have a glance at the project : Click Here

Quick look at the code:

 


/********************************************************************
* Button Press Function *
* For Game WacAMole Version 0.5.0 *
*********************************************************************/
int gameButtonPressed(unsigned long timeStart,int unitLength){
unsigned long timeLoc = millis();
while(timeLoc<=timeStart+unitLength){
buttonDownState = digitalRead(PBD1);
buttonUpState = digitalRead(PBU1);
buttonConfirmState = digitalRead(PBC1);
buttonCancelState = digitalRead(PBC2);
if(buttonDownState == 1){
while(timeLoc<=timeStart+unitLength){
buttonDownState = digitalRead(PBD1);
if(buttonDownState == 0){
return 4;
}
delay(15);
timeLoc = millis();
}
}
delay(15);
if(buttonUpState == 1){
while(timeLoc<=timeStart+unitLength){
buttonUpState = digitalRead(PBU1);
if(buttonUpState == 0){
return 3;
}
delay(15);
timeLoc = millis();
}
}
delay(15);
if(buttonCancelState == 0){
while(timeLoc<=timeStart+unitLength){
buttonCancelState = digitalRead(PBC2);
if(buttonCancelState == 1){
return 1;
}
delay(15);
timeLoc = millis();
}
}
delay(15);
if(buttonConfirmState == 0){
while(timeLoc<=timeStart+unitLength){
buttonConfirmState = digitalRead(PBC1);
if(buttonConfirmState == 1){
return 2;
}
delay(15);
timeLoc = millis();
}
}
timeLoc = millis();
}
return 0;
}
Game Console System On Tiva C Board
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *