Fortune Teller (Week 13)

Goal: The goal of this project, to create the fortune teller using an arduino, thermal printer and capacitive sensor is still the same. The last time I posted I had achieve connecting the capacitive sensor and the printer into a single code. However, I still had no been able to figure out how to get the printer to print is accordance to when the capacity passes the 1000 point threshold, or in other words, when the capacity is touched. Ergo, for this past week my 3 major goals/ obstacles to overcome.

  1. Figure out how to have the printer read and print according to when the capacitive sensor is touched.
  2. Code the arduino to be able to read the capacity and give fortune according to different ranges in the capacity. For example; 1000-1499 (“The world is your oyster”) and also be able to code for if the capacity read is even or odd for another layer of fortune telling.
  3. Have the printer print the fortune.

Assembly: So I made two appointments (knowing that I probably wouldn’t complete this in one day) at the Learning Center. Originally I was trying to connect the printer to print in accordance to the push of a button, but Tubah and I had a lot of difficulties with the button so we jumped straight into using capacity. Eventually by the end of the session we got it connected. However, the printer was unable to print the correct symbols (we were testing with a barcode) matter of fact it was printing an infinite series of illegible symbols. So with task #1 taken off the list I had simultaneously created 3 more.

I was able to conclude from my experience with the Serial monitor that a possible cause of the symbol affliction was due to baud-rate and or Arduino syntax between softwareserial/ mySerial.begin and Serial.begin. I also would have to code a way to make the Arduino read the first number of capacity and then pause so that it wasn’t continuously printing fortunes for the milliseconds a participant may be touching the capacitor. Lastly, the serial monitor was no longer printing the read capacity. I wanted to be able to see the capacity change on the serial monitor so that I could make capacity ranges for fortunes.

  1. Find out how to get the printer and the Arduino speaking the same language.
  2. Code the arduino to be able to read the capacity and give fortune according to different ranges in the capacity.
  3. Code the Arduino to read only the first number of capacity past the threshold and then sleep.
  4. Get the serial monitor to print the capacity
  5. Have the printer print the fortune.

The following Monday I met with another tutor at the Learning Center, Aarati. She was amazing and helped me find the problems in my code. My intuition was right, the baudrate for the printer was changed from 9600 to 19200, which allowed the printer to be able to read the code and print correctly. Tangent from this, with small changes to the syntax of the code we were able to get the Arduino and the serial monitor to connect on the right level, thus presenting the capacity in the monitor. Lastly we even finished early enough to add in an “odd and even” if-else statement to the fortune code allowing for if the capacity if even an “evil fortune” if the capacity is odd a “nicer fortune.”  

How it works:

This is intro code to how the Fortune Teller tells it fortune. By defining several specific ranges of capacity I am able to tell the printer to print an according fortune.

The ranges I have thus far:

Capacity >= 1999 — Fortune
Capacity >= 1750 — Fortune
Capacity >=1499 — Fortune
Capacity >=1250 — Fortune
Capacity >= 1000 — Fortune
Capacity == 666 — Fortune

Materials:

  • A mini thermal receipt printer – with cables and plastic mounting shims
  • A roll of 50′ long thermal receipt paper – the perfect amount for the thermal printer. BPA-free.
  • 5V 2A power supply – an ideal supply for powering the thermal printer (and anything else that can use 5V power
  • 2.1mm DC jack adapter – makes it easy to attach the power supply to the printer
  • 6x MM jumper wires –
  • 1x LED
  • High Powered Resistor

My next step of this process is now to construct the the fortune Teller itself, solder a new clean board and clean the code up a little.

Some of my new goals are:
1) Find a way to add a text box around the code
2) Possibly make the presentation of the fortune a little more aesthetic
3) Build a nice sturdy stand to hold to box up right.
4) Make a robe and hand.

Thermal Printer Library

Thermal Printer

Thermal Printer Setup  

  • Assembly:
  • Plug in the GND (black) and VH (red) F wires into the printer
    Cut off the open end of the Red and black wires to expose the metal inside.
    Using the DC adaptor put in the exposed black and red end of the wires
    Make sure they are oriented correctly
    Plug in the GND (black), RX (yellow) and TX (Green) wires into the printer
  • Using the 3 MM jumper wires attach them to the open end of the GND, RX and TX cord.
  • Insert the TX (green) wire into the digital ~5 pin of the Arduino
  • Insert the RX (yellow) wire into the digital ~6 pin of the Arduino
  • Insert the GND (black) wire into the GND (any of them) of the Arduino
  • Highest Resistor (150.5K) ~4pin and ~8pin
  • Power Cable LED ~7pin
  • Ground Cable LED GND.
  • Download the Thermal Printer Library
    Change the baud rate from 19200 to 9600 by accessing the source code.
    If your printer test page shows ‘BAUDRATE: 9600’, you’ll need to make a small change to the library source code.
    Go into your computer files where the  Thermal Printer Library is being stored and using a text editor (Notepad, etc.) open the file Adafruit_Thermal.cpp
    Ctrl-F ‘BAUDRATE’ and change this line from 19200 to 9600.
    Save and exit.

Leave a Reply

Your email address will not be published. Required fields are marked *