In one scene of 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. We loaded it with the same sonnet, but you could easily use your own love poem.
This version uses Adafruit's Circuit Playground Express to drive 2 OLED displays. The 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. The same text is sent to both displays simultaneously- just because that's the easiest.
ElectronicsIt should be noted that we used a generic I2C oled rather than Adafruit's version, which has a few more pins. The pins may also be populated in a different order so be sure to check the label on the board. The Adafruit's version has a reset pin that must be connected to A0 (used as digital pin 6). If your OLED board doesn't have a reset pin (like ours), don't worry about it.
The only difficult task in this project is changing the address of one OLED. This means moving a very tiny resister. Everything else in this project is at the easy level. For reference of scale, the tiny resistor is shown with a penny and grain of rice.
We printed our case and provided STL files. Don't let lack of 3D printer keep you from making this fun project. You should be able to modify a heart shaped candy box to fit your electronics. This might even be easier. 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.
Please note for the files provided, the displays have support pads with no holes. we used hot glue at those locations. We used two 2.5mm screws to mount the CPX board. I painted our box with some pastel acrylic paint.
ProgrammingInstallation:
This project used the standard Arduino IDE to program the Circuit Playground Express (CPX). Please make sure these items are installed first.
- Arduino IDE
- Adafruit display Libraries
- SAMD Boards (includes CPX)
After you install the Arduino IDE, you will need to add 2 Adafruit libraries to use this code (if you don't already have them). 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.
We highly recommended that you restart Arduino IDE. If you are using windows, you may need to install drivers. Adafruit has wonderful instructions.
Modifications:
If you want to use Elizabeth Barrett Browning's Sonnet 43 ("How do I love thee? Let me count the ways..."), then just download the program and you are good to go. The code will advance the poem one line at a time each time the heart is turned over.
The poem is stored as an array of strings. This is the only variable you need to change to make it your own. Perhaps you want to personalize it with your sweetheart's name. 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. If you are interested in modifying the code, consider the following snippet
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.
Only the first 2 strings of the poem are shown above, even though it looks like more. 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.
Comments