Pirate Game

BOM:

buzzer x 1

servo x 1

arduino x 1

breadboard x 1

jumper wires x 5

Schematic:

Connect the buzzer to pin 9 and the servo to pin 11.

treasure game

 

Code:

https://github.com/jimmyadg/lab-2/blob/master/treasureGame/treasureGame.ino

 

Process:

I calibrated x indicator to 40 degree, y indicator to 15 degree, skull to 45 degree, and treasure to 95 degree.

I modified the tone in setup to a higher frequency.

tone(11, 3000, 1500);

 

sat the toneFreq to 2000.

int toneFreq = 2000;

 

and change to the won tone to higher frequency.

tone(11, 3000, 200);
delay (200);
tone(11, 4500, 200);
delay (200);
tone(11, 9000, 200);
delay (200);
tone(11, 12000, 200);

 

I also added the code to make the servo turn to either X or Y when the player guess X or Y right, and print that the guess is correct in the serial port.

if(treasureX == inputX) {
Serial.println(“X is correct!”);
myservo.write(40);
}
if(treasureY == inputY) {
Serial.println(“Y is correct!”);
myservo.write(15);
}

 

 

Demo Video:

Leave a reply

Skip to toolbar