Slot Machine

by : Edward Yuen, Nathan Guan, and Ben Liu

Project Description

Our ECE153B project is going to be a slot machine that utilizes 3 LED Matrices with I2c backpacks, a 7-segment display with an I2c backpack, and a GPIO button on the LPC4088 Logic Board. Pressing the GPIO button will trigger an interrupt that will tell the LPC to "spin" the three LED matrices and then display 3 random numbers. If all three numbers match, your score will increase and will be updated on the 7-segment display.

We were able to turn on the LED matrices and the 7-segment display by sending i2c messages to specific addresses within each of the matrices and the display. We began by turning on the oscillator and the display on each. Then we sent 'numbers' encoded as hexadecimals to the specific data registers within the peripherals such that the 'number' would show up on the matrices and display.

With the basics down, we implemented different functions, such as 'spin' and 'scoreBoard', to mimic that of a slot machine. Using the GPIO button, we enable interrupts with each click such that the score board would update and the three LED matrices would spin and randomly display a number.


Week 1

This week, we ordered the parts from the Adafruit website that we linked in the project description. We are currently studying the HT16K33 backpack data-sheet which is the driver for our LED's and 7-segment display.

Week 2

Our parts came in and we have soldered our LED Matrices and 7 Segment displays to their respective i2c backpacks. We spent most of the lab trying to figure out how to interface our LED's with our LPC4088 Microcontroller but have found it difficult because the source code and included libraries relied on Arduino libraries. We have learned that rather than import libraries, we will have to write our own functions that abstract away the individual i2c transmissions that will display numbers on the LED matrices.

Week 3

We finally got our LED's light up with I2c. Everything we needed was in the data sheet which contained the specific byte commands that we needed to send to the LED matrix through I2c. The LED's could be turned on one at a time by first sending each LED a 0x21 byte which turns on the peripheral's oscillator (clock). After that we could send a specified blink rate to each LED with a byte between 0x80 and 0x87 which will determine the blink rate (.5 hz, 1 hz or 2 hz). We also got all 3 LED matrices working at the same time by wiring the Vcc, ground, SDA, and SCL all on parallel.

Week 4

During week 4, we "drew" our numbers onto the LED's by writing our own drawing functions for each individual number. These functions involved multiple i2C sends of different commands to obtain the proper number. After writing a function that displays a specific number, we wrote a "spin" function that would imitate the spinning of a slot machine by displaying many random numbers quickly. We then interfaced this with a GPIO button on the LPC board and caused the spinning to occur only on an interrupt triggered by a button press. We included debouncing as well.

Week 5

During week 5, we got our 7-segment display properly working. Now we have included variables that keep track of the current score and we update the "score" on the 7-segment display during and after every single spin. We also added flashing to signify that the current spin has completed.