This year we are challenged to make a pinball machine for our culminating project for our Engineering Pathway.
Above it the requirements lost for our project.
This project will use all disciplines of STEAM.
Today we reviewed how to code a working LED stoplight.
We learned wiring best practices and received a breakout boards and used them to practice our wiring using the stoplight from before.
We coded our breakout board and practiced using the serial monitor to improve our troubleshooting and create code to make our indicator lights appear in rapid succession.
We saved our code in Github: https://github.com/Tarsh-Freeman-IV/LED-Chaser.git
Our class took a trip to an arcade to research pinball machines. At the arcade, we found mechanical components that are similar in all pinball machines, one of which is the start button. The start button starts the game by releasing the pinball.
Another mechanical component common in all pinball machines is the launcher. The launcher is a spring-loaded knob that when tugged all the way back builds up potential energy and when released, releases kinetic energy that will send the ball onto the playing field.
Common component #3 is a target/drop target. A target is a flat mechanical piece that is held up on a small ledge and when its hit with a ball it is moved backwards and dropped down using a small spring.
A more complex common component is the bumpers. Bumpers are open switches, the switch is always open until the ball hits the bumper which closes the switch. When the switch closes the top of the bumper clamps down causing the ball to be sent away.
After we added the LCD to the pico we added buttons. Our goal with the buttons was to have the LCD respond to the buttons. In order to know if the LCD responded we coded the buttons to increase the score and decrease the ball count. Here is the code for both buttons responding.
Github Link: https://github.com/Tarsh-Freeman-IV/Scoreboard.git
9/13/2023 OnShape Drawing Practice 1-4 in Engineering
Rectangles
We used the corner rectangle, dimensional, and linear pattern tool.
Rectanlges and Cirles
Robot Sides
Stairs
Today we measured our LCD to create a mount. The outline of the screen was the easier part of this task. The most tedious part of this task was perfectly fitting the holes. After we got everything to fit we mounted the LCD and mount to our pinball machine.
9/27/2023 OnShape Drawing Practice 5-8 in Engineering
Pyramid
Donut
Target body
Cone
What is the function of a flipper? The function of a flipper is to keep the ball on the playing field while also allowing the player an opportunity to aim at targets and score points.
Describe in your own words, once your flipper is installed, how you will consider it to be successful. As of this year, one of the expectations of your engineering knowledge is that you can develop your own set of constraints. Use the target constraints as a guide. Develop a comprehensive list of project constraints for your flipper/bumper (10-20 requirements).
Find some videos (at least three that contribute to your understanding) and explanations of how pinball flippers work. Place the videos in your Google site. Include a description of how/what the specific video helped you understand about the inner workings of the bumper/flipper. Answer these questions in detail: What is the “switch” that controls the mechanism? Describe it. Add an image of one. What is the electromechanical component that creates the movement? Add an image of one. What is the mechanical component that hits the ball? Describe it in words, but also draw a 3D Sketch of the assembly (on paper). Add this sketch to the entry.
We implemented our scoreboard and targets into our pinball machine shell and connected them to work in tandem.
Playable board with moving parts
Wires, labels, components, and power
import board
import digitalio
import time
import busio
import neopixel
from digitalio import DigitalInOut, Direction, Pull
from adafruit_motor import servo
import pwmio
score_button=digitalio.DigitalInOut(board.GP5)
score_button.direction = digitalio.Direction.INPUT
score_button.pull = digitalio.Pull.UP
ball_count_button=digitalio.DigitalInOut(board.GP9)
ball_count_button.direction = digitalio.Direction.INPUT
ball_count_button.pull = digitalio.Pull.UP
score_buttonb=digitalio.DigitalInOut(board.GP18)
score_buttonb.direction = digitalio.Direction.INPUT
score_buttonb.pull = digitalio.Pull.UP
score_buttonc=digitalio.DigitalInOut(board.GP10)
score_buttonc.direction = digitalio.Direction.INPUT
score_buttonc.pull = digitalio.Pull.UP
from lcd.lcd import LCD
from lcd.i2c_pcf8574_interface import I2CPCF8574Interface
ball_count_button.value
score_button.value
score_buttonb.value
score_buttonc.value
score = 0
ball_count = 3
i2c = busio.I2C(board.GP1, board.GP0)
# Talk to the LCD at I2C address 0x27.
lcd = LCD(I2CPCF8574Interface(i2c, 0x27), num_rows=2, num_cols=20)
lcd.set_backlight(True)
RED = (225, 0, 0)
BLUE = (0, 150, 230)
BLACK = ( 0, 0, 0) # 0% of all colors (turns the LED off)
led_strip1_pin = board.GP19
led_strip1_num_pixels = 5
led_strip1 = neopixel.NeoPixel(led_strip1_pin, led_strip1_num_pixels, brightness=0.3, auto_write=True)
led_strip1.fill(BLACK)
led_strip1.show()
led_strip2_pin = board.GP4
led_strip2_num_pixels = 5
led_strip2 = neopixel.NeoPixel(led_strip2_pin, led_strip2_num_pixels, brightness=0.3, auto_write=True)
led_strip2.fill(BLACK)
led_strip2.show()
led_strip3_pin = board.GP6
led_strip3_num_pixels = 5
led_strip3 = neopixel.NeoPixel(led_strip3_pin, led_strip3_num_pixels, brightness=0.3, auto_write=True)
led_strip3.fill(BLACK)
led_strip3.show()
led_strip4_pin = board.GP7
led_strip4_num_pixels = 5
led_strip4 = neopixel.NeoPixel(led_strip4_pin, led_strip4_num_pixels, brightness=0.3, auto_write=True)
led_strip4.fill(BLACK)
led_strip4.show()
led_strip5_pin = board.GP8
led_strip5_num_pixels = 5
led_strip5 = neopixel.NeoPixel(led_strip5_pin, led_strip5_num_pixels, brightness=0.3, auto_write=True)
led_strip5.fill(BLACK)
led_strip5.show()
flipper1_solenoid = DigitalInOut(board.GP2)
flipper1_solenoid.direction = Direction.OUTPUT
flipper1_solenoid.value = False
flipper1_button = DigitalInOut(board.GP12)
flipper1_button.direction = Direction.INPUT
flipper1_button.pull = Pull.UP
flipper2_solenoid = DigitalInOut(board.GP21)
flipper2_solenoid.direction = Direction.OUTPUT
flipper2_solenoid.value = False
flipper2_button = DigitalInOut(board.GP13)
flipper2_button.direction = Direction.INPUT
flipper2_button.pull = Pull.UP
flipperb_solenoid = DigitalInOut(board.GP16)
flipperb_solenoid.direction = Direction.OUTPUT
flipperb_solenoid.value = False
flipperb_button = DigitalInOut(board.GP15)
flipperb_button.direction = Direction.INPUT
flipperb_button.pull = Pull.UP
flipperb2_solenoid = DigitalInOut(board.GP11)
flipperb2_solenoid.direction = Direction.OUTPUT
flipperb2_solenoid.value = False
flipperb2_button = DigitalInOut(board.GP14)
flipperb2_button.direction = Direction.INPUT
flipperb2_button.pull = Pull.UP
pwm = pwmio.PWMOut(board.GP17, duty_cycle=2 ** 15, frequency=50)
pwm = pwmio.PWMOut(board.GP20, duty_cycle=2 ** 15, frequency=50)
my_servo = servo.Servo(pwm)
servo2 = servo.Servo(pwm)
my_servo.angle = 0
servo2.angle = 0
while True:
#lcd.clear()
lcd.set_cursor_pos(0,1)
lcd.print("Ball Count")
lcd.set_cursor_pos(0,12)
lcd.print("#:")
lcd.print(str(ball_count))
lcd.set_cursor_pos(1, 1)
lcd.print("Score: ")
lcd.print(str(score))
#lcd.clear()
time.sleep(.001)
#lcd.clear()
if score_button.value == True:
print("button not pressed")
led_strip1.fill(BLACK)
led_strip1.show()
if score_buttonb.value == True:
print("button not pressed")
led_strip2.fill(BLACK)
led_strip2.show()
if score_buttonc.value == True:
print("button not pressed")
led_strip3.fill(BLACK)
led_strip3.show()
if score_buttonb.value == False:
score = score+45000
if ball_count_button.value == False:
ball_count= ball_count-1
if score_buttonc.value == False:
print("scorebuttonc pressed")
score = score+20000
led_strip3.fill(BLUE)
led_strip3.show()
time.sleep(.001)
if score_buttonb.value == False:
print("scorebuttonb pressed")
led_strip2.fill(BLUE)
led_strip2.show()
if score_button.value == False:
score = score+30000
print("scorebutton pressed")
print("led 1 is on")
led_strip1.fill(BLUE)
led_strip1.show()
time.sleep(.001)
if (flipper1_button.value == True):
flipper1_solenoid.value = False
led_strip4.fill(BLACK)
led_strip4.show()
else:
# The button is pulled to ground, so the switch is pressed
flipper1_solenoid.value = True
led_strip4.fill(BLUE)
led_strip4.show()
if (flipper2_button.value == True):
flipper2_solenoid.value = False
led_strip5.fill(BLACK)
led_strip5.show()
else:
# The button is pulled to ground, so the switch is pressed
flipper2_solenoid.value = True
led_strip5.fill(BLUE)
led_strip5.show()
if (flipperb_button.value == True):
flipperb_solenoid.value = False
else:
# The button is pulled to ground, so the switch is pressed
flipperb_solenoid.value = True
score = score+50000
if (flipperb2_button.value == True):
flipperb2_solenoid.value = False
else:
# The button is pulled to ground, so the switch is pressed
flipperb2_solenoid.value = True
score = score+75000
for angle in range(0, 180, 5): # 0 - 180 degrees, 5 degrees at a time.
my_servo.angle = angle
for angle in range(180, 0, -5): # 180 - 0 degrees, 5 degrees at a time.
my_servo.angle = angle
for angle in range(0, 180, 5): # 0 - 180 degrees, 5 degrees at a time.
servo2.angle = angle
for angle in range(-180, 0, -5): # 180 - 0 degrees, 5 degrees at a time.
servo2.angle = angle
Target
When hit the target depresses the button underneath the board closing the circuit and increasing the score.
Flipper
When the button is pressed a signal is sent through the relay which causes the solenoid to extend making the flipper hit.
Bumper
The bumper has copper tape on the top and bottom, when hit by the ball the circuit is closed and the bumper closes pushing the ball away.
Servo
Once coded spins 360 degrees either clockwise or counter-clockwise in intervals decided in the code.
Scoreboard
An LCD screen is coded to display printed text and straights triggered by compenents on the board.
Unique Mechanical Component
A servo motor is mounted sideways to the board with the wooden part to give it the circular movement.
Neopixels
Neopixel strips are given RGB values and if statements to display a certain color when triggered.
Launcher
A spring is loaded up with potential energy to then expel kinetic energy onto the ball and push it across the board.
The pinball project was full of research, professional aid, troubleshooting, and emotions. This was the most difficult project of my life close to none. The most similar experience I have to this is building my gaming pc, I built my pc all by myself which was full of challenges in and of itself. The only experience I had to back it up was watching LinusTechTips on Youtube. I ran into problems similar to the pinball board where I had to replace faulty components and rearrange my wires. Completing this project gave me a feeling of solace, I spent many hours on this project and specifically some parts such as soldering the LEDs. What I'm most proud of is being very determined to learn from my mistakes. From my rough draft I was able to adjust my components to work more efficiently and I even through times of hardship and discouraged I was able to make my LEDs work properly.