Fancy over complicating a simple task in order to try out some nice bits of Arduino kit this Christmas? If so, then this Secret Santa Machine is the project for you.
It does what it says on the tin and using a full colour TFT screen, it invites by name each person on the list to press the giant red button.It then prints them a ticket with their secret Santa person on using a thermal printer module.
It uses an Arduino, the Adafruit ST7735 1.8” colour display and the thermal printer module from Cool Components.
Adafruit TFT display
Download and install the latest version of Arduino IDE (IDE = Integrated Development Environment) on your computer from Arduino.cc
Add the library for the TFT display to the Arduino IDE; open Arduino, navigate to Sketch > Include Library > Manage Libraries
In the Library Manager search bar, type Adafruit ST7735. When the library for it appears,click install.
Now do the same for the Adafruit GFX and Adafruit Zero DMA libraries as shown here.
Finally restart the Arduino IDE so the libraries are correctly loaded.
Download the Secret Santa Machine Arduino code from the Github page and open it in your Arduino IDE.Now plug your bare Arduino into your computer with the USB lead and confirm the Arduino IDE can find your Arduino board OK like this:
We are now ready to take a look at the hardware.We will start with the TFT display. The Adafruit page gives pin out details for the display as follows:
The first step is to cut the strip of header pins to the correct number to fit the board and then solder them onto the TFT display. Make sure you put the short legs up through the circuit board from underneath, leaving the long legs ready to plug into the breadboard when soldering is finished. You only need to solder them on the top side like this:
Follow the great Adafruit breakout assembly guide for this. When you are finished, click through to their next page on wiring and test.
We are now going to use the dedicated SPI pins on Arduino to interface with the display. You can connect it in a different way using other pins, but communication will be much slower.
In the Arduino IDE go to Examples > Adafruit ST7735 > graphics test and run the example code to test the display works.
In case you are new to Arduino, you click on the Upload icon to upload the code to your Arduino board.
Now it is time to look at the thermal printer.Load the thermal paper roll into the printer and close the door with some paper protruding past the cover.Make sure the thermal side of the paper is facing down onto the print head. You can test it by scraping your thumbnail across a piece of the paper and the heat from friction will leave a dark mark.
Wire up the printer TTL serial cable with three wires as follows: Black to GND, yellow (printer RX) to pin 7 and green (printer TX) to pin 6 of the Arduino. Now connect the red and black power cables for the printer to the DC barrel jack connector. Red is +9Vdc and black is the GND. Also add an extra red jumper wire to the +9V side of the DC barrel jack connector and connect the other end to Vin on the Arduino–now your machine will run even when the USB cable is not connected.Remember the printer uses quite a bit of power as it prints, so we have to use a 9V power supply that can provide at least 2A. The image below also shows the illuminated push button connected–we will cover that in a bit.
Test the thermal printer by keeping its button on the front held down while you power it up with the 9v power supply. It should print out a status page similar to this:
Note the serial baud rate; in this case it is 19200bps, so we use that in our code to communicate with it. You can also see the supply voltage, here it is 8.9v.
Now it is time to upload the main Secret Santa Arduino code. Download it first from the GitHub page for Secret Santa Machine and then open it in the Arduino IDE. At the top of the code is the string people. This is the list of the Secret Santa participants. Simply enter each name with inverted commas around it and a comma to separate them.Double check your 9V power supply is plugged in and switched on and then upload the code to your Arduino board and see if it runs, following the prompts on the screen, it should print a ticket for each person. If you get two names where you expect one, you forgot a comma.If you need to run the code again, simple press the reset button.
If everything is working, you can mount the machine into a box. To do this you may want to use some of the male to female jumper wires to extend the screen off the breadboard like this:
The box can be made out of 1.5mm thick mount board available in almost any colour. There is an EPS file for laser cutting here or in pdf version here or finally just the front panel template you can print out on A4 paper here, just ensure the printer is set to ‘no scaling’rather than the standard ‘fit to size’.