Martin, in Year 7, worked with his father to make and program a pinball machine for the school’s charity Christmas fair, using an Arduino to control the pinball switches and the score LCD display. Martin explains more below:
Pinball Machine explanation
Our Pinball Machine was controlled by an Arduino Uno and used 4 micro switches as well as a 16 x 2 LCD display. We used the LiquidCrystal library code to print text and numbers onto the LCD screen. This shows the current score, the high score and the amount of turns remaining.
The 4 switches connect to 4 digital pins on the Arduino. They are set up with input pullups. The switches are normally open and connect the input pins to 0V when they are closed. 3 switches are used to score points when they are hit by the ball. They score 20, 35 and 50 points when they are triggered. These values are added to a running total score which is printed on the LCD. The fourth switch is triggered when the ball goes out of play. This decrements a counter of the number of turns left. When this reaches zero, “**Game Over***” is printed on the LCD.
Each time the score increases, it is compared against the high score. If it is bigger, the high score is set to that value. If it is lower, it stays as it was before.
Each time a new game starts, the running score is set to zero.
Featured Image Details:
Photo by Kittisak. Published on 09 December 2011
Stock photo – Image ID: 10066784