Robert Chenpranaym12Jiin RhewAudrey Yao
Published

The Tomato Timer (Pranay M, Robert C, Jiin R, Audrey Y)

We built a tomato timer that incorporates the Pomodoro technique to boost your productivity and help push you through midterms and finals!

BeginnerFull instructions provided3 hours627
The Tomato Timer (Pranay M, Robert C, Jiin R, Audrey Y)

Things used in this project

Hardware components

Grove - Ultrasonic Ranger
Seeed Studio Grove - Ultrasonic Ranger
×1
Buzzer
Buzzer
×1
Display Driver, LCD 4 Digit
Display Driver, LCD 4 Digit
×1
Grove Starter Kit for LaunchPad
Seeed Studio Grove Starter Kit for LaunchPad
×1
EK-TM4C123GXL TM4C Tiva LaunchPad
Texas Instruments EK-TM4C123GXL TM4C Tiva LaunchPad
×1

Software apps and online services

Energia
Texas Instruments Energia

Hand tools and fabrication machines

EPILOG Fusion M2 40
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Custom parts and enclosures

Box (Adobe Illustrator File for Laser Printer Compatibility)

7"x4"x5" laser cut wooden box made from 0.2" wood. Parts are joined by hot glue in original design to keep one side open for battery removal. Each part is cut twice (with the front face detailing removed for the back face).

Schematics

Video of the Tomato Timer

Schematic

Schematics for Tomato Timer

Code

Tomato Timer

C Header File
This program utilizes the ultrasonic ranger to measure distance of the user and runs an internal clock to check the passed time and displays it on the 4-digit display. When the time is over, the buzzer is triggered to buzz three times
#include "TM1637.h"
#include "Ultrasonic.h"
#define CLK 37  //pin number defined for 4 digit display
#define DIO 36
#define DELAY_VALUE 1000  //delay for the clock. Currently set to 1s(1000ms) but set to 20ms when testing
#define WORK_TIME 1500  //length of each working cycle in seconds. 25 mins
#define PLAY_TIME 300  // length of each rest cycle in seconds. 5 mins
#define BUZZER_PIN 39 //pin number for the buzzer
#define ULTRASONIC_PIN 24  //pin number for the ultrasonic ranger

TM1637 tm1637(CLK,DIO);
Ultrasonic ultrasonic(ULTRASONIC_PIN);    /* Ultrasonic Ranger object */
int distance = 0;  //distance value for the distance from the ranger, initialized

void setup()
{
  //set up for display and buzzer
  tm1637.init();
  tm1637.set(BRIGHTEST);//BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
  pinMode(BUZZER_PIN, OUTPUT);
  Serial.begin(9600); 
  delay(1000);  //delay start by 1 second
}
void loop()
{
  int8_t NumTab[] = {0,1,2,3,4,5,6,7,8,9};//0~9,A,b,C,d,E,F
  int8_t ListDisp[4]; //list of values to be displayed for each output of 4 digit display
  unsigned char i = 0;
  signed int s = WORK_TIME; //stores value of total number of seconds left, decrements
  unsigned int s_display = 0; //seconds to be displayed after converting to min:sec
  unsigned int m = 0; //minutes for display stored.
  boolean is_work = true;
  signed int sitting_distance = 0; //the distance from the device that the user starts at. Does not change after initial recording. 

  
  while(1)
  {
    // if sitting_distance is 0, then store the distance that the person is sitting at
    if(sitting_distance == 0) sitting_distance = ultrasonic.MeasureInInches();
    // current distance
    distance = ultrasonic.MeasureInInches();

    // if distance is within 2ft of sitting_distance and is_work is true, then decrement s.
    // if is_work is false, decrement s regardless of distance
    if((distance <= (sitting_distance + 24) && is_work == true) || is_work == false){

      // calculate for each digit of the display.
      // display will be shown as ListDisp[0]ListDisp[1]:ListDisp[2]ListDisp[3]
      m = s/60;
      s_display = s % 60;
      ListDisp[0] = m / 10;
      ListDisp[1] = m % 10;
      ListDisp[2] = s_display / 10;
      ListDisp[3] = s_display % 10;

      // Assigns all digits of the display w/ the correct ListDisp
      tm1637.display(0,ListDisp[0]);
      tm1637.display(1,ListDisp[1]);
      tm1637.display(2,ListDisp[2]);
      tm1637.display(3,ListDisp[3]);
      tm1637.point(true); //sets colons between min and sec 
      delay(DELAY_VALUE); //time delay.
      s--;

      //checks to see if the transition between work time and rest time(playtime) is needed. If so, buzz
      if(s == -1){
        playBuzz();
        is_work = !is_work;
        if(is_work) s = WORK_TIME;
        else s = PLAY_TIME;
      }
    }

    // If the user is not within 2ft from the initial sitting distance, then check every half second to 
    // check whether the user has returned to the space. 
    else delay(DELAY_VALUE/2);


    
    
  }
}

/* helper function to play the buzzer three times */
void playBuzz() 
{
  for(int j = 0; j < 3; j ++){
    for (long i = 0; i < 1000 * 1000L; i += 1432 * 2) 
    {
      digitalWrite(BUZZER_PIN, HIGH);
      delayMicroseconds(1432);
      digitalWrite(BUZZER_PIN, LOW);
      delayMicroseconds(1432);
    }
    delay(500);
  }
  
  
  
}

Credits

Robert Chen

Robert Chen

1 project • 0 followers
pranaym12

pranaym12

1 project • 0 followers
Jiin Rhew

Jiin Rhew

1 project • 0 followers
Audrey Yao

Audrey Yao

1 project • 2 followers

Comments