3D Printed Good Habits Tracker
by Ondřej Beneš in Workshop > 3D Printing
1755 Views, 21 Favorites, 0 Comments
3D Printed Good Habits Tracker
When trying to develop a good habit, the most important and probably hardest thing for me is to keep it going long enough until it becomes a routine in my life. I know good habits can have a great impact on my life and it usually makes me feel good right after I read a couple pages of a book, do a quick workout or practice the guitar. Despite that, I usually end up dropping the good habit eventually because I get "too busy", distracted or simply forget to do the routine one day. So I have decided to do something about it and keep track of the good habits I am trying to develop.
Because of it's simplicity, this is a great project to get started with coding, wiring, 3D modeling and printing. But it is also a project that you can go crazy with and come up with overcomplicated implementations. I can think of a number of modification just writing this introduction and will discuss the future possibilities at the end of this instructable.
Supplies
This build uses very basic parts and tools, which makes it easy and cheap to create. The only exception could be the actual 3D printer. Despite 3D printers being more affordable than ever before, it can still be a big expense for some people. But don't worry, there are ways you can get stuff 3D printed for you without having a 3D printer. More on that later in this instructable.
Essential:
- 4x LED (you can pick your favourite color or go with RGB LED for most flexibility)
- 4x toggle switch
- 4x magnet 5x3 mm
- ESP8236 (or any microcontroller really, more on this in the section below)
- Jumper wires
- 4x Resistor 220 ohm (12 if you want to use all 3 RGB colors)
- 4x Resistor 1k ohm (for switches)
"Non-essential"
- 3D printer
- Breadboard
- Soldering iron
- Solder
The Electronics
For this project you need to wire the toggle switches and LEDs with the ESP8266 board. Below you can see the diagram with the wiring. The RGB LEDs are used in this project because you can get them cheap, you can get any color out of them and they allow for future improvement of the project. For this time, I decided I will only use green color so only one of the color pins needs to be wired.
I started by wiring only one switch and LED on the breadboard using some jumper cables and then trying each the other switches and LEDs to test if they are working as expected. Once all components are tested you can wire all of them. To make the connection more permanent, you can solder them together or just wire it using jumper cables, the enclosure has enough space inside to cover all the wiring.
Repeat the connection for each switch-LED combination. Using pins 1D to 4D for LEDs and 5D to 8D for switches.
The Code
The code for this project is quite simple. All we need to do is to make the LED turn ON and OFF when we move the toggle switch from one position to another. Bellow, you can see the code that needs to be uploaded to the microcontroller.
To upload the code, I used the Arduino IDE. I only had to adjust some preferences and install a package for the ESP8266. You can follow this tutorial, for example:
https://randomnerdtutorials.com/how-to-install-esp8266-board-arduino-ide/
- First, we need to define our variables, these represent the pin number on the microcontroller.
- Then, in the setup() method, we need to specify are actually input for LEDs and output for the switches
- Lastly, we need to write the logic of our code. This happens in the loop() method which runs continuously, checking for the state of each light switch. If any of the switches is in the ON position then the coresponding LED is turned ON and OFF when the switch is in the OFF position.
- And that's all!
/*Switch pins*/ int switch1_pin = D1; int switch2_pin = D2; int switch3_pin = D3; int switch4_pin = D4; /*LED pins*/ int led1_pin = D5; int led2_pin = D6; int led3_pin = D7; int led4_pin = D8; void setup() { pinMode(switch1_pin, INPUT); pinMode(switch2_pin, INPUT); pinMode(switch3_pin, INPUT); pinMode(switch4_pin, INPUT); pinMode(led1_pin, OUTPUT); pinMode(led2_pin, OUTPUT); pinMode(led3_pin, OUTPUT); pinMode(led4_pin, OUTPUT); } void loop() { if(digitalRead(switch1_pin) == HIGH){ digitalWrite(led1_pin, LOW); } if(digitalRead(switch1_pin) == LOW){ digitalWrite(led1_pin, HIGH); } if(digitalRead(switch2_pin) == HIGH){ digitalWrite(led2_pin, LOW); } if(digitalRead(switch2_pin) == LOW){ digitalWrite(led2_pin, HIGH); } if(digitalRead(switch3_pin) == HIGH){ digitalWrite(led3_pin, LOW); } if(digitalRead(switch3_pin) == LOW){ digitalWrite(led3_pin, HIGH); } if(digitalRead(switch4_pin) == HIGH){ digitalWrite(led4_pin, LOW); } if(digitalRead(switch4_pin) == LOW){ digitalWrite(led4_pin, HIGH); } }
The Enclosure
Once all the parts are tested, code uploaded and our first prototype is working as expected, it is time to turn the huge mess of wires, LEDs and switches into something, more "sitting on a table, looking good" like "gadget". To do this, I decided to design simple enclosure that can be 3D printed and snapped together without any need of glue or screw.
I used FreeCad the "open-source parametric 3D modeler" to design each part of the enclosure but there are number of other alternatives such as Autodesk Fusion 360 or for complete beginners the TinkerCad. TinkerCad is very basic, browser based 3D modeler that I would recommend if you are just starting with 3D modeling or I personally use it for rapid 3D modeling, quick reference, or to design simple stuff like the icons used in this project.
The enclosure needs to house all the parts mentioned at the beginning, cover all the wiring and to have access to the power supply of the microcontroller. Each part is also designed to just fit into each other so there is no need for glue or screws.
All the files to either 3D print or modify the design are attached bellow
The Front Part
For the front part, you need to create holes based on the diameters of the switches, LEDs and magnets and make the holes accordingly.
The toggle switch can then be attached using the nut. 6mm hole
LEDs should hold on their own if the hole is just tight enough. 5mm
The magnets should fit precisely into their holes, with use of bit of a strength or you can use solder iron, heating them up a bit which helps with the insertion. It is IMPORTANT to make sure you know which side of the magnet is facing from the enclosure part as the opposite pole needs to be facing from the icon.
In case you do not own a 3D printer, it is possible to look for maker spaces or workshops near you, just google "maker spaces near me" and maybe you will find a gem in your location. Alternatively, there online service that can print the parts for you but pricing may vary.
The Habit Icons
The front panel of the enclosure now houses 4 switches and 4 LEDs for 4 different habits of choice. But what if you would want to change the habits you are currently working on, for whatever reason, or you might have already mastered one of the four and need new challenge? Well, that's where the habit icons come in. The front panel of the enclosure has 4 magnets which can be used to attach 3d printed icons representing whatever habit you would like to encourage. Each icon has a magnet inside as well that attaches on the front panel.
Attached are 4 different icons I created. Each represents diffrenet habit I am aiming to improve:
- Reading
- Exercise
- Training with dogs
- Guitar practise
There is also 1 "blank" stl file where you can add icon of your choice. The icons were made in the Tinkercad previously mentioned. You just need to make square with a 5mm hole for the magnet, download icon representing your habit in .svg format or png that can be converted into svg file. You then just import the svg into tinkercad and place it on top of the square. You can convert png to svg using any vector based software or using online converters such as:
https://convertio.co/png-svg/
Great tinkercad tutorial for beginners:
https://www.instructables.com/TinkerCAD-Tutorial-1/
To make the icon stand out, I did setup a color change in the prusaslicer, changing a filament with different color at the just when the icon's shape is beinng printed to get the icon in different color.
Color change in prusaSlicer:
https://www.youtube.com/watch?v=CtC5vAK94qA&ab_channel=Prusa3DbyJosefPrusa
And We Are Done
Future Improvements
I do realize that there are some aspects of this project that are not perfect and could be improved. And that is exactly what I like about projects like this. You start with some basic requirements and design the functionality and everything else accordingly. After couple failures such as bad print for the enclosure, you always learn something and it makes you think and that is when the ideas start popping in my head. So by the end of this first prototype, I have already come up with couple improvements for future:
Electronics:
The enclosure has enough space inside to fit all the messy wires and hide some imperfections but I would like to improve this by creating a custom made circuit, which does not have to be as difficult as it might sound especially for simple project like this. This should make the whole thing more replicable, easier to assemble and way better looking.
IoT capability:
The main reason to use the ESP8266 board was, well because it's cheap but also because it has a WiFi module. With this capability, there are number of possibilities. You can track and store the progress of your habits in the cloud, connect the habit tracker to a network of other IoT devices such as smart mirror (on my todo list), or pull the data into a custom made application. You can then setup daily/weekly/monthly streaks, reminders, analytics on how well you are performing, throwing a pinch of gamification into the mix.
Enclosure:
The enclosure, at the moment, is very simple and some amendments will be needed once the above improvements take place. It will need better design to house all the components nicely but the great thing about it is that only your imagination is the limit.
Battery powered:
Currently the controller is powered via micro USB cable and everything else takes power via the controller. But the enclosure should fit some smaller/medium sized LiPol battery. And since there are only few components, the whole habit tracker should stay powered for quite some time.