A model slot machine simulates the real thing by flickering 3 led’s in the three windows. The various fruits in the windows are depicted by different brightnesses of the LED. The blur of the fast spinning wheels is accomplished with Fade statements.

This is a playable random machine where each wheel has a chance of stopping on different fruits. When all three wheels have stopped, the result is the brightness of each fruit.

If LED’s face forward through the windows, they may be quite bright. Use Theme Designer to turn them down significantly.

There are two versions, identical except for the brightness of the fruits. The playable version has easily discernible fruits, so you can see if you won. The visual version has softer contrast, which might look more realistic in a model.

The file is too large to list here. We included the opening lines showing where the two versions are selected. Comment out one version or the other. The full length is attached.

//Slot Machine 
//3 LED's for the 3 viewing windows
//each LED depicts one wheel

//spins for a time similar to mechanical slot machines, adjustable
//spinning depicted by rising falling brightness of each LED

//brightness depicts cherries, oranges, etc.
//random as to which fruit each wheel stops on


//visual version - brighnesses flutter subtly 
define bar 100% 
define cherries 50%
define seven 30% 
define grapes 17%

//playable version - brighnesses easily identifiable
//define bar 100% 
//define cherries 35%
//define seven 12.2% 
//define grapes 4.3% //add more fruities (and code) if desired


define spinMore 100ms //how fast wheel rotates to next position in the machine's window
                      //fixed spinning time of each wheel is not shown below
define wheel1Ending 20% //three wheels spin, higher = longer variable time
define wheel2Ending 40% //two wheels spin, higher = longer variable time
define wheel3Ending 40% //one wheel spins, higher = longer variable time
define spinFadeRate 80ms //longer = more blur to the eye

//spin all three wheels for fixed length of time, plus a short variable time

Download the complete file:

Slot-Machine-final.zip