The Official Raspberry Pi Projects Book - Projects_Book_v4

(singke) #1

raspberrypi.org/magpi The Official Raspberry Pi Projects Book 63


PI BASH Projects


adjusted to suit the player; a reset
button; and the aforementioned
scoreboard. “Once I had all of
these working individually, I built
the wooden support structure and
started to add them together,”
recalls Steve. “I could then
tune the sensing calculations
to make it feel as realistic as
possible.” There wasn’t much
programming involved, although
the sensing code, written in C, was
fairly complex.


What are the scores?
The scoreboard was tricky to make.
Rather than using a screen, Steve
wanted to use three large seven-
segment LEDs to make the score
clear, “but I couldn’t find anything


appropriate for sale, so I built
one myself.” The seven-segment
displays were connected to a
laser-cut Perspex mount which
Steve built at Makespace.

“I bought the LEDs online,
along with the components to
build controllers for them,” he
adds, referring to the resistors,
shift registers, optocouplers,
and connecting wire. “This was
one of the more challenging
parts of the project.” The lights

FAIRGROUND ATTRACTION


>STEP-02
Lighting the way
The information is sent to the Raspberry Pi, which
loops and counts up to this value. It triggers updates
to the LED strip and the scoreboard via a GPIO port.

>STEP-03
Ring that bell
If the measured power is enough to reach the top, the
relay is triggered, again via a GPIO port. It connects the
12 volts to the bell, which then rings. Success!

>STEP-01
Give it a whack
When you go for a strike, a hit triggers the vibration
sensor. The Arduino calculates the power of the strike
based on the amount of vibration, and converts it to a
number between one and 100.

and sensors also proved tricky to
control, so they remain connected
to the Arduino at the moment.
More difficult, though,
is actually achieving a high

score, but the reaction to the
Pi Bash has been great. “I’ve
got a couple of sensitivity
settings so parents and youngsters
can compete on a more equal
footing. We had a lot of laughs
at the Pi Birthday Party earlier
this year.”

I’ve got a couple of sensitivity settings


so parents and youngsters can compete


on a more equal footing

Free download pdf