
Pinskiball
Carnival Game
Cornerstone of Engineering 2
Feb-Apr 2024
As a group project for Cornerstone to Engineering 2, we were tasked to create a carnival game that two players could play simultaneously. Two players start with 3 balls each, then launch them simultaneously into the tubes. The tubes lead into the funnel and points are earned based on the hole into which they land their ball.
_HEIC.png)

/*Code for Pinskiball carnival game. This code reads from 3 distance sensors to determine which point hole the object landed in, and then differentiates the player who launched the object based on the color of the object (black or white) using three separate IR sensors. For each point scored, a light sequence is triggered. The code then totals the points for each player and displays all information to an LCD screen. Written By: Josiah Lamirand, Kaitlin Rattray, Lauren Ayres Version: 6.0*/ #include //include library for LCD screen //set pins for distance and ir sensor 1 const int trigPin1 = 38; const int echoPin1 = 40; const int IRPin1 = 42; //set pins for distance and ir sensor 2 const int trigPin2 = 47; const int echoPin2 = 49; const int IRPin2 = 51; //set pins for distacne and ir sensor 3 const int trigPin3 = 46; const int echoPin3 = 48; const int IRPin3 = 50; //set pins for lights const int yellowPin1 = 22; const int redPin1 = 24; const int yellowPin2 = 26; const int redPin2 = 28; const int yellowPin3 = 30; const int redPin3 = 32; //initialize point values for each player int player1Points = 0; int player2Points = 0; //set pin for point total switch int inputSwitch = 33; //initialize distance meausurements for all 3 sensors float distance1 = 0; float distance2 = 0; float distance3 = 0; #include LiquidCrystal lcd(13, 12, 11, 10, 9, 8); //set pins for lcd void setup() { Serial.begin(9600); // Initialize serial communication //set pinmodes for distance and ir sensor 1 pinMode(IRPin1, INPUT); pinMode(trigPin1, OUTPUT); pinMode(echoPin1, INPUT); //set pinmodes for distance and ir sensor 2 pinMode(IRPin2, INPUT); pinMode(trigPin2, OUTPUT); pinMode(echoPin2, INPUT); //set pinmodes for distance and ir sensor 3 pinMode(IRPin3, INPUT); pinMode(trigPin3, OUTPUT); pinMode(echoPin3, INPUT); //set pinmodes for lights pinMode(yellowPin1, OUTPUT); pinMode(redPin1, OUTPUT); pinMode(yellowPin2, OUTPUT); pinMode(redPin2, OUTPUT); pinMode(yellowPin3, OUTPUT); pinMode(redPin3, OUTPUT); //set pinmode for point total switch pinMode(inputSwitch, INPUT_PULLUP); lcd.begin(16, 2); lcd.clear(); //print starting message to screen lcd.setCursor(0, 0); lcd.clear(); lcd.print("Pinskiball!!"); delay(4000); lcd.clear(); } void loop(){ while (true){ //functions for reading distances from the three sensors distance1 = getDistance(trigPin1, echoPin1); distance2 = getDistance(trigPin2, echoPin2); distance3 = getDistance(trigPin3, echoPin3); if (distance1 < 2){ //if distance sensor 1 reads an object lcd.setCursor(0,0); lcd.print("5 points (1)"); //print five points lightSequence(IRPin1); //call light sequence function for ir sensor 1 lcd.clear(); break; } else if (distance2 < 2){//if distance sensor 2 reads an object lcd.setCursor(0,0); lcd.print("5 points (3)"); //print five points lightSequence(IRPin2); //call light sequence function for ir sensor 2 lcd.clear(); break; } else if (distance3
_heic.png)



