This is only a preview of the May 2022 issue of Silicon Chip. You can view 39 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "AM-FM DDS Signal Generator":
Items relevant to "500W Power Amplifier, Part 2":
Articles in this series:
Items relevant to "Slot Machine":
Purchase a printed copy of this issue for $11.50. |
U
O
R OW
Y
D
L
I
N
U
B
GIANNI PALOTTI’S
JACKPOT
A slot machine is a game where you insert a coin, and the machine randomly chooses a
combination of symbols. Depending on what symbols turn up, you might get a payout;
rare combinations could net you many times what you put in. They can be fun to play but
it gets expensive if you’re using real money. Why not build this machine with colour
graphics and sound; it’s just as fun to play, but you can’t lose your shirt!
T
his slot machine displays four
virtual wheels, each with 17
symbols drawn from a set of
six: cherries, a bell, a bar, the number
seven, a lemon and a bonus starburst
(see Fig.1). It is based on a Micromite
Plus LCD BackPack, producing colour
graphics and sound.
To keep things simple, this Slot
Machine differs a little from a real
slot machine that has the symbols in
a fixed order on the wheels. Instead, it
randomly selects one of the six symbols for each wheel over the 17 ‘runs’
or ‘loops’. Each symbol showing at the
end of each cycle therefore has six possibilities. Still, as this is updated over
17 cycles, the possibility of repeating
the same symbol too often is avoided.
The design includes a 5c coin input
slot; this gives the player a more realistic ‘casino’ feeling when compared to
a typical downloadable slot machine
game. The standalone cabinet also
makes it more interesting than any
old app.
I made the coin input from a funnel
with a reflective photosensor. Every
time a coin passes through, a highto-low signal transition is sent to the
Micromite Plus LCD BackPack around
which the game is based, and it adds
one credit in response. It has a limit
Fig.1: the six possible symbols that randomly appear on the four ‘wheels’ during
play. The payout varies depending on what combination is shown in Fig.2.
of three credits (coins) per spin, and
wins are calculated accordingly, based
on the chart shown in Fig.2.
You could use a pushbutton instead
of a coin slot, but that would remove
some of the fun.
An add-on module offers the possibility of a solenoid-operated ‘kicker’ to
eject any coins collected into the coin
tray. This can be done by operating a
tilting table, or the coins can be ejected
into a thin tube (with an internal diameter slightly bigger than the 5c coins)
located under the coin input funnel.
However, the details of those
options are not described here and
will be left as an exercise for the
reader. Some changes to the overall
case dimensions would be necessary
to implement either option.
Operation
Once power is switched on, the program starts an initialisation routine
which sets up the sound module and
loads images from an SD card using
the BLIT READ command available
on the Micromite Plus. Once the initialisation is complete, the gamer can
insert coins into the slot. The first
coin will activate the “PlayReady”
LED, and the “Play 1 Coin” button
becomes active.
You can choose the number of coins
you would like to play by continuing to
push this button or hold it down until
no more coins are transferred from the
“CREDITS” box into the “COINS IN”
box. The maximum number of coins
you can play for each spin is three.
When “Spin Wheel” is pushed, it
changes the symbols displayed on the
screen using the “BLIT WRITE” command, based on random numbers generated by the RND(TIMER) function,
which tells the computer to use its
internal clock value as a random seed.
This number is then further processed
Slot Machine Payouts
●
●
●
1
●
●
●
2
●
●
3
●
5
●
5
●
8
Values
above
the red
line are
multipled
by the
amount
of coins
inserted
(up to
three
coins).
10
●
18
20
●
25
30
●
50
JACKPOT
Fig.2: the payouts that are given depend on the result of the spin. For example, if you get “7 cherry lemon cherry”, that’s
two cherries, so you get a payout of three if one coin was inserted, six if two were inserted or nine if three were inserted.
siliconchip.com.au
Australia's electronics magazine
May 2022 77
Fig.3: the circuit of the Slot Machine is simple as most of the work
is done by the Micromite. It triggers audio playback by sending
commands to the DFPlayer Mini module, which connects to the
loudspeaker via CON1. The rest of the circuit is mostly a power supply
and a way to interface to the pushbuttons, LED and coin sensor.
to achieve an almost-random value
from 1 to 6.
The process is then repeated 17
times to simulate the wheels spinning,
after which the result is analysed and
any payout is processed, as per Fig.2.
The addition of sound effects makes
this unit more fun and adds to the
78
Silicon Chip
reality of the game. After all, the point
of playing slots is to have fun!
Circuit details
The main circuit is shown in Fig.3.
It’s based around the Micromite Plus
LCD BackPack (November 2016 issue;
siliconchip.com.au/Article/10415).
Australia's electronics magazine
This has a powerful onboard PIC32MX470F512H 32-bit 120MHz processor plus a 320x240 pixel colour
touchscreen that’s used as the display
and for user input.
The touchscreen has a 3.2-inch
(8cm) diagonal measurement compared to the 2.8-inch (7cm) screen
siliconchip.com.au
Parts List – Slot Machine
1 Micromite Plus LCD BackPack (without touchscreen) loaded with
SlotMachine V10.bas [Silicon Chip Cat SC6211]
2 microSD cards loaded with sounds & images
1 3.2-inch LCD touchscreen with ILI9341 controller
1 4-pin female header (to mount the touchscreen to the BackPack)
1 double-sided PCB coded 08105221, 76 x 53mm
1 DFPlayer Mini audio player module [Silicon Chip Cat SC4789]
1 5V DC coil SPDT relay (RLY1) [Omron G5LE-5V or CIT J107F1CS125VDC] ●
7 2-pin headers, 2.54mm pitch (CON1, CON3, CON9-CON13)
1 4-pin header, 2.54mm pitch (CON2)
1 PCB-mount DC barrel socket (CON4)
1 2-pin polarised header and matching plug, 2.54mm pitch (CON5)
2 8-way female headers, 2.54mm pitch (CON6, CON7)
1 18-way male or female header, 2.54mm pitch (CON8)
1 9V battery clip to barrel plug (optional)
1 3W 4W miniature loudspeaker
1 grille to suit the loudspeaker
1 panel-mount slide or toggle switch (power on/off)
3 square miniature panel-mount pushbuttons (Collect, Spin & Play Coin
buttons) [Jaycar SP0716 or Altronics S1080] ▲
1 red panel-mount LED in a square housing [eBay item #353825669342]
1 PS126EL1 paper sensor (optional, for coin sensing)
various jumper wires
various M3 machine screws, nuts, washers and spacers (for mounting the
PCBs, coin sensor etc)
Hardware
1 300 x 350mm sheet of 7mm plywood
1 136 x 95mm sheet of 14mm plywood
1 150 x 130mm sheet of 3mm black perspex/acrylic ■
3 65 x 52mm sheets of 3mm black perspex/acrylic ■
1 100mm length of 20 x 12mm aluminium angle
2 M5 x 15mm hex socket cap head machine screws
4 No.4 x 10mm self-tapping black screws for mounting the front panel
4 M4 x 10mm panhead machine screws & nuts
3 M4 x 6-7mm panhead machine screws
2 M3 x 20mm panhead machine screws & nuts
14 No.4 x 15mm wood screws
Semiconductors
1 7805 5V 1A linear regulator (REG1)
1 2N2222A 40V 600mA NPN transistor (Q1) ●
1 1N4004 400V 1A diode (D1) ●
Capacitors
2 100μF 10V electrolytic
2 100nF multi-layer ceramic
Resistors (all 1/4W 5%, small body types if possible)
2 10kW
1 2.4kW ●
6 1kW
2 1kW ●
1 120W
▲ add one more button if a coin sensor is not being fitted
■ or purchase laser-cut pieces from the Silicon Chip Online Shop (Cat
SC6181)
● these components are only needed for the optional ‘coin kicker’
normally used for this BackPack. That
larger size makes it better suited to the
Slot Machine. Since it has the same
number of pixels as the 2.8-inch screen
and a compatible controller chip, it’s a
direct swap; the only consideration is
that the mounting holes no longer line
up with the BackPack PCB.
siliconchip.com.au
Because of this, I glued a 4-pin
female header to the outer side of
CON4 on the BackPack to provide
extra anchorage for the screen.
The components besides the BackPack and LCD are hosted on another
PCB that adds just a few things to the
BackPack:
Australia's electronics magazine
•
•
•
•
a simple linear power supply
some buttons and LEDs
the coin sensor
a DFPlayer Mini digital audio
player, described in the December 2018 issue (siliconchip.com.
au/Article/11341).
This PCB concentrates all the extra
connections into two sets of wires, one
9-way and one 3-way, that emanate
only from one side of the BackPack.
The DFPlayer Mini is responsible for producing all the sounds. It is
wired to a miniature 73 x 51mm 4W
3W speaker mounted in the back of
the Slot Machine.
Power comes from a 9-12V DC plugpack or battery through a DC barrel
jack or direct USB input to the BackPack.
Micromite control
Programming the Micromite Plus
LCD BackPack is easy as it is done
in BASIC. The software configures
the COM port required to control the
DFPlayer Mini music player module
(COM2), sets the correct music files
source (micro SD slot) and sets the volume to the required value (20).
The BASIC code can be downloaded
from the Silicon Chip website and
loaded into the BackPack in the usual
manner, eg, using TeraTerm or MMEdit
to load the software into the BackPack
over its USB virtual serial port.
Once running, the coin input generates an INTH command which runs
a routine where the number of coins
inserted is registered without affecting
other operations or music playback.
The rest of the code is based on which
button is pressed and how much credit
is available at the time.
In addition to loading this software,
you must load each audio file on the
micro SD card in the correct order.
The sound effects are also part of the
download package, although the ‘background music’ is not included as it
depends on your taste. Select a music
track and convert it to a 44.1kHz 16-bit
stereo WAV file. The files must then
be copied into a folder named “mp3”
on the micro SD card in the following order:
1. Background music track
2. Coinin.wav
3. Play1Coin.wav
4. RunArm.wav
5. SpinWheel.wav
6. NoWin.wav
7. Jackpot.wav
May 2022 79
The main screen for the Slot Machine
indicates your total winnings (or
losses!)
To get the files in the correct order,
it’s best to copy them one at a time.
However, you can prefix the files with
a four-digit number, to guarantee the
correct playback order. We have done
this for the supplied files.
For example, the first file would be
prefixed with 0001, the second file
with 0002 etc.
This is because the DFPlayer only
plays a file based on its order in the file
system and does not look at the actual
file name, unless it has a numeric prefix as mentioned above.
The image files must be loaded
on a separate micro SD card in the
BackPack slot. These files are named
“SlotScreen1.bmp”, “SlotScreen2.
bmp” and “PayOutChart.bmp” and
are included in the download package.
Most of the parameters in the
code can be easily modified to suit
your preferences. This includes the
‘rewards’. Note that any code changes
to PAUSE(delay) commands can alter
Fig.4: assembly of
this add-on PCB is
straightforward; start
by soldering the lowestprofile components and
then work your way
up to the taller types.
As most of the headers
connect elsewhere
via jumper wires, you
could substitute male
for female headers or
vice versa, depending
on what jumper wires
you have.
* only for the coin kicker
the coordination between the sound
and program sequence.
Electronic assembly
Build the Micromite Plus LCD BackPack as per the instructions in the
November 2016 issue (link above)
and, once it’s up and running, load the
BASIC code (“SlotMachine V10.bas”)
onto it as explained earlier.
Next, build the extra circuitry on
the PCB coded 08105221 (76 x 53mm).
Follow the overlay diagram, Fig.4.
There isn’t much to it – solder the
resistors as shown (use small body
resistors or bend the leads close to the
bodies), followed by diode D1 orientated as shown, then transistor Q1 and
the two 100nF non-polarised capacitors. Then fit the headers, including
the two 8-way female headers CON6
and CON7 (not visible in Fig.4 as they
are under the DFPlayer Mini module).
Note that you can use a male or
female header for CON8 depending
on what type of header you have fitted to the BackPack, and what sort of
jumper wires you intend to use to join
the two boards.
Follow with the DC socket, then
the electrolytic capacitors with their
positive (longer) leads towards the
bottom or right side of the PCB, as
shown. Then mount REG1 with its
tab towards the edge of the PCB, followed by RLY1 if you are using the
coin kicker option. Finally, plug the
DFPlayer into its socket with the
micro SD card socket entry towards
the nearest board edge.
Note that if you’re using the coin
sensor, the 120W and 1kW resistors
specified may be suitable, or they
might need to be changed, with either
possibly being a higher value. For this
reason, extra 1kW and 2.4kW resistors
are specified in the parts list. You can
swap them out later if you find the coin
sensor doesn’t work well with the initial resistor values.
The wiring
is relatively
straightforward,
with most
connections
running between
the two main
boards.
Coins are ejected
via the underside
of the Slot
machine, so you
might want to
put a small tray
underneath it to
catch them.
80
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
Fig.5: cut the plywood shapes as shown. Note the dotted outlines that show how the various parts fit together. Don’t
forget that the ‘floor’ is made from thicker (14mm) plywood. You could use other materials such as MDF or even acrylic.
Chassis assembly
Now we move on to building the
cabinet. It’s mostly made from plywood and perspex, with a couple of
metal brackets. The plywood cutting
details are shown in Fig.5, while the
perspex and metal pieces are shown
in Fig.6.
To save some effort, we can supply
laser-cut perspex pieces made from
3mm-thick black acrylic (see the parts
list); or download the templates from
siliconchip.com.au/Shop/11/6443
Fig.5 also shows how some of the
siliconchip.com.au
other pieces mount to the side panel.
So once you’ve made all these pieces
and cut and drilled the holes, assemble them as per Fig.5 and the photos.
The 3mm black perspex front panel
is where the coin slot, LED screen, three
pushbuttons and LED are mounted.
This panel can be made of two separate
components or formed from a larger
piece, by bending it at the required
point to a 110° angle after heating it (eg,
with a hot air gun). If bending it, make
the cut-outs after the panel is formed
to avoid them distorting.
Australia's electronics magazine
Our laser-cut front panels are supplied as two separate pieces. You could
fill the joint with black silicone after
assembly if you want to.
The 5¢ coin input unit is made from
the same material as the front panel.
Our laser-cut set includes these four
pieces, which are assembled as shown
on the right side of Fig.6. The correct
location of the sensor opening must be
worked out according to the final sensor or microswitch selected.
Once all the pieces are ready,
...continued on page 84
May 2022 81
Fig.6: the front panels (upper left) can be made from two flat pieces or
one bent piece, as depicted at right. Making the metal brackets is simply
a matter of cutting the aluminium angle to length and drilling some holes.
The four remaining acrylic pieces shown opposite are assembled to form
the coin chute as depicted at lower right.
The Micromite
Plus LCD
BackPack that
controls the
whole Slot
Machine is
based on Geoff
Graham's
Explore 64
(shown at
actual size).
82
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
We will be supplying a double-sided
PCB for the add-on module of the Slot
Machine from our Online Shop.
This is the 3W speaker I used. It
works well and I recommend it, but
there are plenty of other options.
siliconchip.com.au
Australia's electronics magazine
May 2022 83
Fig.7: here is how to wire it all up. Switch S4 is not
needed if you’re using the coin sensor and vice versa
(although you could have both if you want). The
power switch can be any type that can handle the
current. Take extra care with the wiring between
the add-on board and the BackPack, especially the
GND, 5V & 3V3 cables or you could fry something!
If using the optional switch (S4) for Coin In
instead of the coin sensor then you will need an
additional cut-out for another pushbutton on the
lower front panel. The dimensions of this will be
provided in the download for the front panels on
the Silicon Chip website.
assemble the cabinet using small 3mm
wood screws, ensuring that each holding hole is fully pre-drilled so that
the plywood does not split. Once
complete, the box can be primed and
painted as required. To allow coins to
slide out of the base, glue a thin section of material (preferably perspex)
to the top face of the floor.
You can use any metal or plastic
lid from any suitable container for the
84
Silicon Chip
coin catching tray. I was fortunate to
find one of exact size that only needed
to be cut around the edges to make a
suitable shape. Use the small black
self-tapping screws to attach the front
panel on either side.
Wiring
After the chassis has been assembled, you’re ready to mount the
BackPack, control board and other
Australia's electronics magazine
electronic components and wire it up.
See the photos, which show where the
various parts go. Those photos should
also help you figure out the wiring, but
for clarity, we’ve also provided a full
wiring diagram in Fig.7.
Double-check the wiring between
the control board and the BackPack
before powering the Slot Machine up
since a mistake there could cause damage to either or both boards.
SC
siliconchip.com.au
|