Mint Drawing Tin
By Paul Verras
Overview: The Mint Drawing Tin will allow you to create, save, and view simple drawings and animations. All components will be housed within an Altoids tin, meaning it will fit right in your pocket. It's perfect for those who want to be creative on the go!
Current Hardware List
- (1) Altoids Tin
- (1) OLED Screen
- (1) Arduino Nano
- (7) Tactile Switch Buttons
- (1) Digital Slide Switch
- (1) Mint Tin Breadboard
- (1) 3.7 V 1200 mA LIPo battery/ Charging Board
- (1) 3D-Printed Casing
Week 1: Hardware Components/ Interfacing
- Digital Pin Connections (no interfacing necessary)
- (1) Slide Switch and (7) Tactile Buttons
- I have not tested these, but have experience with them in class and have made sure that the Arduino has enough pins to accommodate them.
- SSD1306 OLED Display
- Connected to Arduino Nano (I2C)
- I have tested to make sure the screen works properly with the Nano by displaying a simple animation. I also used some of the sample code from the class/ Adafruit libraries.
- I am a bit worried about whether or not the Arduino Nano has enough memory to store the drawings and animations, so I may look into using the ESP8266 instead!
- Connected to Arduino Nano (I2C)
- Portable Charging Device
- I will be using a 3.7 V 1200 mA LIPo battery
- This will be paired with a charging board, and will hopefully allow the tin to be powered for a few hours. The board will connect to the Nano via the VCC pin.
- I will be using a 3.7 V 1200 mA LIPo battery
- Adafruit SSD1306
- Adafruit GFX
- I will decide whether or not I am using the GFX library at some point down the road.
Week 2: Trials and Tribulations/ Roadblocks
- Unfortunately, I had to completely nix the original concept of making a drawing pad using a light pen and LDRs. Light sensing proved to be way too finicky, and due to the small size of the Altoids tin, the LDRs were just not precise enough. To replace the light pen, I am going to use a simple directional pad. This will be constructed using four digital tactile buttons and a 3D-printed top.
- It was becoming a real hassle to wire everything up on a breadboard. Luckily, I was eventually reminded that each pin of the Arduino has its own built-in pull-up resistor! I was using a separate resistor for every button before I figured this out. Now, my circuit is a lot more simple and elegant, and I can just have a path from each digital pin, to the button, and then to GND.
- My original intention was to allow users to save images and (SHORT) animations to the Arduino, so that they can view it even after turning everything off. This means that I will need to save data to EEPROM. I have no idea how to do that. Let's hope Google knows what it's talking about.
- The OLED screen was a bit hard to figure out, mostly because each block in my 16 x 16 drawings are actually made up of 4 x 4 pixels, and the drawings need to be centered in the screen. So, moving and drawing a single square actually needs to cover four pixels each time. I eventually figured out how to best do this, and I believe my code is pretty optimal at this point.
- I seem to have miscalculated the dimensions of my 3D prints. Most of it was on point, but I forgot to double-check the length of the legs for each digital button. The buttons rest on top of base plate, and the legs just weren't long enough to go through the bottom of the plate where they would be soldered. Luckily, Rui was able to quickly print my improved design for me.
Week 3: Updates
- I finished a rough design of my final plans on a breadboard, including the Arduino Nano, OLED screen, and all digital buttons. I did not include the digital slide switch, mostly since it is not really breadboard friendly. I also don't plan on containing everything within the Altoids tin for the time being, although I am keeping an eye on the size of my project so as to make sure it will still fit eventually.
- I have my completed 3D casing design. I just need to check to make sure all of the measurements are correct, and account for precision issues.
- I have received my perf-board and Altoids tin, so I am ready to put everything together once I get the battery
- I have decided on the best way to place everything within the Altoids tin. I plan on implementing a layered design of sorts, where the battery/charging board will be on the bottom, following by the perf-board/Nano, and then topped with the 3D printed casing, which will hold all seven of the digital buttons.
Still in Progress:
- The code is close to being finished. As of now, I can move around, draw, erase, and animate different drawings. All that is really left is to implement the menu interface. I will finish this within the week.
- I need to learn how to save images to EEPROM so that they can be viewed after turning off the device (this will probably be the most challenging part of the software side of this project. Hopefully I will get this done in about a week.
- I still need to properly implement the rechargeable battery. I have never dealt with them before, so I am a bit hesitant. That being said, once I receive the charging board, I will start working with it more in-depth. I hope to mostly deal with this during our final lab section.
- I need to figure out how to prop open the Altoids tin while it is in use (it is a bit uncomfortable to just hold it open with your hand). I may try to create a make-shift hinge for the final product. This will be dealt with closer to the due date, if at all.
Week 4: Current demo
Here is a quick video of my project so far. Pardon the crude setup. It'll be a lot cleaner and more compact once everything is soldered. Since the menu has not been made yet, I used the right-most button to "animate" for this demo. This will be changed in the future. Also, it isn't very clear in the video, but the white cursor that appears on the black squares does become black when on white squares. In the video it doesn't look like a cursor appears on white squares.
Here is a description of the buttons used in the demo.
Here is a closer look at the circuitry.
Here is a look at the casing for my project. The plan is for everything to be inside the Altoids tin by the end of the week. As you can see, I was able to get a tin-sized perf-board to solder.
Week 5: The Software
I have final thought through and implemented the software side of my project. Here are a few things to note:
- I use a blinking cursor to signify where in the drawing the user are positioned at a given time. This cursor appears white on black squares and black on white squares. This proved to be a hassle to implement, since apparently you can't just "read" pixel values directly from the OLED screen. So, I actually had to use a array that stored all pixel values and check the value at each position whenever the cursor moved.
- Since the screen is monochrome, and the drawings are only 16 x 16 blocks*, I realized I only need 256 bits of data to store each drawing or frame of animation. I use a byte array with 32 element to store each image, which actually makes it pretty easy to save drawings to EEPROM, since you can (and must) write/read each byte individually.
- My menu ended up being a bit simpler than intended, but in the end it gets the job done. The main menu has five options: "Create Image", "Create Animation", "View Images", "View Animations", and "Save". Beyond that, there are mostly just very simple menu screens, such as the screen to choose between saved images. Before this project, I never really noticed how much of a hassle it can be to create intricate and engaging menu interfaces!
Week 6: Putting it all together
With the impending project deadline almost upon us, I am finally finishing up the final assembly of my mint tin:
- As mentioned before, I am using a layered design:
- The bottom layer is the LiPoly battery, which is connected to a Micro Lipo charging board. There is a charging port that can be accessed while the tin is closed which was a real challenge to carve out!
- The second layer is comprised of the Arduino Nano, perf board, and all the wiring for the digital buttons.
- The third layer has the 3D-printed base plate, as well as the tactile buttons and the slide switch.
- Finally the last layer, which is on the cover of the tin, simply has the 3D-printed face plate, as well as the OLED screen.