Introduction: Poetry Heart in Motion

In "A Charlie Brown Valentine", children get those conversation hearts and read them. Charlie's sister read an entire sonnet from hers. She had to keep turning it over and over again. I thought it would be fun to make one that could do that. I used the same sonnet, but you could write your own poem. It would be fun for a proposal or promposal.

This project uses Adafruit's Circuit Playground Express (CPX) to drive 2 OLED displays. The CPX's built-in accelerometer is used to detect when someone picks it up or turns it over. Each time it is turned over, the display advances to the next line of the poem.

Supplies

Heart-shaped box such as chocolate box or 3D printed one (stl files provided)

Electronics

  • Adafruit Circuit Playground Express
  • 2x OLED displays such as Adafruit SSD1306 oled
  • Li-Ion Battery or other power source

Software

  • Arduino IDE & additional libraries
  • sketch file (.ino) provided

Tools

  • Soldering iron
  • Hot glue gun

Step 1: Electronic Connections

Make sure each OLED has a different address. You may need to resolder a jumper on the display. That is the only difficult task in this project. Everything else in this project is at the easy level. For reference of scale, the tiny jumper is shown with a penny and grain of rice.

Connect the displays to the Circuit Playground Express (CPX) as shown in the wiring diagram. Note, you might not need to make the blue connection if your OLED doesn't have a reset pin. If you use Adafruit's OLED, you must make this connection. The pin locations on your OLED may differ, so be sure to read the pin labels.

  • Black GND
  • Red +3V
  • Yellow SCL
  • Orange SDA
  • Blue RST / A0

Step 2: Programming- IDE Setup

This project used the standard Arduino IDE to program the Circuit Playground Express (CPX). It also requires a few additional libraries: 2 Adafruit display Libraries & the SAMD Boards driver.

If you don't already have these libraries, the easiest way to do this is from the tools menu, select Manage Libraries. In the type drop-down box, choose contributed. In the topic drop-down box, choose display. Put Adafruit in the search filter box. The two libraries you will want to add are Adafruit GFX library and Adafruit SSD1306.

Similarly, you will need to add the CPX board with the Boards Manager. From the Tools menu, select Board menu ( or Board: "your default board") to get a drop down menu. Select Board Manager. You need to install the Arduino SAMD Boards version 1.6.16 or later. Type Arduino SAMD in the top search bar, then when you see the entry, click Install.

I highly recommended that you restart Arduino IDE. If you are using windows, you may need to install additional drivers. Adafruit has wonderful instructions.

Step 3: Programming- Text Customization

Use Elizabeth Barrett Browning's Sonnet 43 ("How do I love thee? Let me count the ways...") or follow this step to customize your own text.

The provided program stores a message as an array of strings. The code will advance the message one string at a time each time the heart is turned over. This array of strings is the only variable you need to change to make it your own. You may also want to change the text size. The font size used in the code is much smaller than shown in the cover photo. Consider the following snippet with the first two strings from the poem:

int textSize = 1 ;
String Poem[] = { "\n\n"
	"How do I love thee?\n\n"
	"Let me count\n the ways.\n\n (over -> )",
	"I love thee to the\n"
	" depth and breadth\n"
	"and height My soul\n"
	" can reach, when\n"
	"feeling out of sight\n\n (over -> )",

The textSize variable can be 1, 2, or 3, with 3 being the large size shown on the project cover photo. Size 1 is very small, but still readable on a good quality OLED.

Even though it looks like more, only the first 2 strings of the poem are shown above. If a line ends in a " and the next line begins with a ", the string is continued. To separate strings, a comma must be used.

String Formatting issues: The \n may look a little strange. Including it in the string forces a new line. Without it your text will wrap, but it might break in the middle of a word. The \n is known as an escape character. Other useful escape characters are \t for tab and \' for single quote. (This poem has a single quote). One more formatting problem you might encounter is the percent sign. You must make it double instead (%%). I wish I could link to a good formatting reference at arduino.cc site. So far the best I have found is at Wikipedia. If you have a favorite online reference, please share.

Step 4: Heart-shaped Case

Whether you use a 3D printed box or a candy box, I recommend fixing the displays in place while they are on. This will help you keep them straight and you won't accidentally mount it upside down. Use electrical tape to cover exposed contacts and secure the components, including the battery.

The 3D print files provided support the displays with pads. Use hot glue on those pads.The CPX board is mounted with two 2.5mm screws. Pastel acrylic paint ton the box makes it look more like a conversation heart.

Heart Contest

Participated in the
Heart Contest