Bar tab tracker

Made by Jesse Park, Savanthi Murthy and John Soh

Wake up in the morning and glance at how much you spent at the bar the night before ;)

Created: February 3rd, 2016


Problem Statement

Whenever you go out to drink with your friends, you tend to spend more than you want to. This device is designed to let you know discretely how much money you have spent the night before. When you wake up, you'll immediately know by glancing at the wine bottle.



The goal is to track how much money has been spent at the bar in the bottle. Every time you spend money in the bar using a credit card, an email will be sent. IFTTT then sends a signal to the Particle that changes the color of the green LED's in the bottle to red. More red light you see in the bottle, the more money you have spent. 



Components used:

1 - Particle Photon and breadboard

14- RGB LEDs

6 - 1k ohm resistors

1 - Glass bottle

1 - Wooden slab with circular cutout

This was the process we used:

1.  The inspiration for this project came from the financial constraints we face when we eat and drink out often. As students, we live on a budget and it is not wise to spend too much when we go out. What better way to learn how much you spent on alcohol last night than from a bottle? To better visualize this concept, we started off with free hand sketches and then moved on to a digital prototype before actually building the device.

Img 5148.jpg.thumb

Concept image.thumb    

2.  We first worked on the hardware part of the device. 3 RGB LEDs were connected in series as a bundle, 5 of these were made.  Since we are tracking the alcohol consumption over a night, we chose to use an elegant olive green wine bottle to create an ambient light which was glance-able, but still clearly indicated it's purpose. A wooden piece was machined and surface-finished to enable the bottle to stand at an angle.

3.  The code is designed to track the invoices sent from the bar or restaurant in the form of an email credit card statement, in real time. In the beginning, all the LEDs are green, indicating that you haven't yet started drinking. Each invoice triggers one bundle of LEDs to turn from green to red. When all the LEDs are red, it indicates that no more alcohol must be consumed tonight as you cannot afford any more. The program is designed to refresh and reset the variables every 24 hours.

4.  The last part of creating this device involved connecting to the mail inbox through IFTTT to search for keywords that indicate an alcohol purchase at a bar. This triggers a cloud function in the program to change the color of an LED bundle from green to red. As the lights in the bottle are more red than green, it is an indication that you should not buy any more alcohol.



To control the LEDs based on incoming e-mails, IFTTT function was used. The bottle would glow green until a certain email was received, in this case set to "restaurant" which was set to the alert set on Mint spend notification email. Initially, we tried to control the lights by publishing an event, which turned too difficult. Hence, we used the call function. To make the 24 hour reset happen, function was used to track the program start time, track current time, and if the difference between the two is 1, the program will reset to the default state, which would be green lit bottle. 

The result was every time a certain amount of money was spent, an email notification would be sent to the user's e-mail, which triggers IFTTT, which triggers the light change. As these accrued, the amount of lights that turn red would change, increasingly making the bottle grow redder.

#include <time.h>
int redPin1 = A0;    // RED pin of the 1st LED bundle
int greenPin1 = D0;  // GREEN pin of the 1st LED bundle

int redPin2 = A1;    // RED pin of the 2nd LED bundle
int greenPin2 = D1;  // GREEN pin of the 2nd LED bundle

int redPin3 = A2;    // RED pin of the 3rd LED bundle
int greenPin3 = D2;  // GREEN pin of the 3rd LED bundle

int redValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int greenValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int eatout = 0; // set eatout value

long int dayChecker = / 86400; // set to check dated
long int currentDay = / 86400; // set to check how long it has passed

int led_park(String event) //set IFTTT connection
  Serial.print("event: "); //serial to track event

  if (event == "led") { //if IFTTT function runs, add 1 to eatout
    eatout = eatout + 1;
  return eatout;

int programStartTime = / 86400; // set program start time

void setup() {
  Serial.begin(9600); // for easy debugging
  Particle.function("lightUp", led_park);
  // Set all pins for output
  pinMode( redPin1, OUTPUT);
  pinMode( greenPin1, OUTPUT);

  pinMode( redPin2, OUTPUT);
  pinMode( greenPin2, OUTPUT);

  pinMode( redPin3, OUTPUT);
  pinMode( greenPin3, OUTPUT);

  startState(); // run start state function


void startState() {
  // set default state of all LEDs to be green
  analogWrite( redPin1, 255);
  analogWrite( greenPin1, 0);

  analogWrite( redPin2, 255);
  analogWrite( greenPin2, 0);

  analogWrite( redPin3, 255);
  analogWrite( greenPin3, 0);
void loop()
  dayChecker = / 86400; // set day checker value using

  int currentTime =; // set current time as
  eatoutblinker(); //run eatoutblinker function

  if(dayChecker > currentDay) { // check daychecker vs currentday and if its the same, reset state to default
    currentDay = dayChecker;
    eatout = 0;

void eatoutblinker() {
//if eatout is triggered once, turn LED bundle 1 red
  if (eatout == 1) {
    analogWrite( redPin1, 0);
    analogWrite( greenPin1, greenValue);

  //if eatout is triggered twice, turn LED bundle 2 red
  if (eatout == 2) {
    analogWrite( redPin2, 0);
    analogWrite( greenPin2, greenValue);

  //if eatout is triggered thrice, turn LED bundle 3 red
  if (eatout == 3) {
    analogWrite( redPin3, 0);
    analogWrite( greenPin3, greenValue);
    eatout = 0;

  Serial.print("eatout ");

Click to Expand
Bar spending ambient awareness project
Jesse Park -


The coding was the most difficult to deal with when multiple people were involved. We continuously used slack to send the edited code, but it eventually got too confusing.  It would be great if there was a GoogleDoc version for particle IDE so that we have one constant version.

An improvement that can be made to our project is an ability to track the exact amount spend at the bar. If we have this data, then we can change the gradient of the RGB led to change from green to led more smoothly, therefore, being more discrete. This can be done more easily if there was a mint integration with IFTTT. However, currently, this feature is not available.

Share this Project


49-713 Designing for the Internet of Things

· 4 members

This course charts the emergence of the now "connected world" to explore the possibilities for future products and connected spaces.

Focused on

Wake up in the morning and glance at how much you spent at the bar the night before ;)