Caffeine Tracker
Kyla Anderson
Kyla Anderson
Front view of the device showing the LCD and Neopixel LED strips on.
This device is designed to help me keep track of my daily caffeine intake. Each light is representative of 20mg of caffeine and totals up to 320mg, which is the upper limit I set for myself. The buttons allow for 4 different inputs: 1 green light, equivalent to about a green tea, 2 yellow lights, equivalent to a black tea, or 5 red lights, equivalent to a coffee, and finally a reset button. The caffeineTracker variable keeps track of the total mg consumed, even beyond the light strips, and displays this number on the LCD screen.
Close up of the LED screen, the text is a little hard to register on the camera in the light!
Photo in use (LCD not showing well in the light)
Picture of the full device with button covers in and powered off
Alternate photo in use where the LCD text is visible
For this video, I demonstrate pressing each of the buttons as the number displayed on the LCD goes up and then resetting it at the end.
Wiring complete on the breadboard
Fully soldered wiring
I originally wanted to use a receipt printer but it was bigger than I anticipated and I couldn't get it to function properly even after troubleshooting several different printer.
I had some issues with the LED but ultimately fixed it after failing to initialize the setup correctly.
Sketch of my original plan before I decided to use an LCD
The final peces began coming together as I laser cut the box to fit all the pieces correctly.
I had some challenges throughout the process of making this device. First of all, I couldn't get the receipt printer I originally wanted to use to work. Despite running different amounts of power through the machine, trying different parts, wires, etc. I couldn't get it to print. Instead I just got small dots of ink if any movement at all. My next challenge was with the buttons. After soldering the buttons, I realized that they were too low, about the same height as the resistors, to fit through the holes I laser cut. The buttons were still pressable. but only if you have small fingers or long nails. I decided to laser cut some covers for the buttons and also color code them, but it didn't function super well all the time so I took them off for the demo and video. In the end, it was still fully functional though, so I was satisfied.
One critique I received was that the device has no capability to store data and will reset every time it's unplugged. I think this is a really interesting idea and I didn't know it was possible to do with the Arduino. In the future, I'd like to look into how to do this since I can see how it would have many more useful applications not only for my device but other projects as well. For my project specifically, making it able to store data would make the device portable which coukld be useful. Another critique on my project was that the graphics are hard to see. This was something I also noticed earlier, and was working to improve. I laser cut the top surface of the box several times, adjusting the design and which parts were rasterized or engraving. I ran into some trouble where the dxf file wasn't exporting properly from the illustrator file where I did the designs. I was eventually able to solve it where I exported the file as a png which worked. However, by the time I got the design I wanted, it was a little too late and I didn't have enough material to re-laser cut the piece again and try modify the power or speed or something to make the design more prominent. Someone suggested doing a wash of paint to make it more visible. I didn't think to do that but it's definitely a good option and something to consider in the future.
In my opinion, I'm generally satisfied with how the project turned out. I was a little worried about completing all the technical aspects within the timeline since I'm not particularly skilled at a lot of the requirements like 3D CAD, programming, physical modeling, etc. Even so, I think I made the project appropriately simple enough that I could finish it in the time given. I think throughout the project I learned a lot of new skills like Fusion 360, laser cutting, and more. Because I'm pursuing communications design, this probably wouldn't have been skills I'd learn otherwise so I was very grateful to have access to instructions on how to do these things. I also learned I'm not particularly good at these skills, especially 3D CAD, but it helped me familiarize myself with some of the language people who use these programs use and also I got to know some of the capabilities and limitations of using 3D CAD to model, and laser cutting vs. 3D printing parts of a project.
Unfortunately due to time limitations and the many other projects happening in my other classes I don't anticipate having time to redo the project or improve upon it in any significant ways. However, if this was on option, I'd like to solve the problems with the buttons to make it more ergonomic and also intuitive in terms of how to use the device. I'd also make the design more evident. maybe using some of the aforementioned strategies recommended to me by others. Additionally, someone suggested using the lights in a more subtle way and somehow diffusing it through the form of the device, which would be something I'd like to explore if given the opportunity.
//Caffeine Tracker
//This code defines four buttons that light up a different number of lights in different colors and then a reset button. There's also a variable caffeineTracker that keeps track of the total amount of caffeine depending on the buttons pressed. This information is then displayed on an LCD screen.
//Button 1 should be wired to pin 2 through a 10kohm resistor
//Button 2 should be wired to pin 3 through a 10kohm resistor
//Button 3 should be wired to pin 4 through a 10kohm resistor
//Button 4 should be wired to pin 8 through a 10kohm resistor
//The Neopixel LED strip should be wired to pin 6
//The LCD should be wired to SCL and SDA appropriately
//I used the Adafruit Neopixel Library and Liquid Crystal I2C Library as well as ChatGPT for help with generating and editing code.
#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define PIN_NEOPIXEL 6
#define BUTTON1_PIN 2
#define BUTTON2_PIN 3
#define BUTTON3_PIN 4
#define BUTTON_RESET_PIN 8
#define NUM_PIXELS 60
// Initialize NeoPixel strip
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
// Initialize the I2C LCD
LiquidCrystal_I2C lcd(0x27, 20, 4); // Set address and size
int caffeineTracker = 0;
int lastButton1State = HIGH;
int lastButton2State = HIGH;
int lastButton3State = HIGH;
int lastButtonResetState = HIGH;
int nextLightIndex = 0;
void setup() {
Serial.begin(9600);
strip.begin();
strip.show();
pinMode(BUTTON1_PIN, INPUT_PULLUP);
pinMode(BUTTON2_PIN, INPUT_PULLUP);
pinMode(BUTTON3_PIN, INPUT_PULLUP);
pinMode(BUTTON_RESET_PIN, INPUT_PULLUP);
// Initialize the LCD with columns, rows, and character size
lcd.init(); // initialize the lcd
lcd.init();
lcd.backlight(); // Turn on the backlight
lcd.print("Caffeine Tracker");
lcd.setCursor(0, 1); // Set cursor to the second row
}
void loop() {
int button1State = digitalRead(BUTTON1_PIN);
int button2State = digitalRead(BUTTON2_PIN);
int button3State = digitalRead(BUTTON3_PIN);
int buttonResetState = digitalRead(BUTTON_RESET_PIN);
// Button Reset - Clear all lights and reset caffeine tracker
if (buttonResetState == LOW && lastButtonResetState == HIGH) {
strip.clear();
strip.show();
nextLightIndex = 0;
caffeineTracker = 0;
lcd.clear(); // Clear the LCD
lcd.print("Caffeine Tracker"); // Reset display
lcd.setCursor(0, 1); // Reset cursor
delay(200);
}
// Button 1 handling
if (button1State == LOW && lastButton1State == HIGH) {
if (nextLightIndex < NUM_PIXELS) {
strip.setPixelColor(nextLightIndex, strip.Color(0, 10, 0));
strip.show();
nextLightIndex++;
caffeineTracker += 20;
}
delay(200);
}
// Button 2 handling
if (button2State == LOW && lastButton2State == HIGH) {
for (int i = 0; i < 2; i++) {
if (nextLightIndex < NUM_PIXELS) {
strip.setPixelColor(nextLightIndex, strip.Color(10, 10, 0));
strip.show();
nextLightIndex++;
caffeineTracker += 20;
}
}
delay(200);
}
// Button 3 handling
if (button3State == LOW && lastButton3State == HIGH) {
for (int i = 0; i < 5; i++) {
if (nextLightIndex < NUM_PIXELS) {
strip.setPixelColor(nextLightIndex, strip.Color(10, 0, 0));
strip.show();
nextLightIndex++;
caffeineTracker += 20;
}
}
delay(200);
}
// Update the LCD display with the current caffeineTracker value
lcd.setCursor(0, 1); // Set cursor to the second row
lcd.print("Total: ");
lcd.print(caffeineTracker); // Display current caffeine value
// Update last button states
lastButton1State = button1State;
lastButton2State = button2State;
lastButton3State = button3State;
lastButtonResetState = buttonResetState;
}