chen yiwen
Published © GPL3+

Time Receipt

This project is a representation for the powerlessness that we have over time, reminding everyone to live in the moment and cherish it.

BeginnerShowcase (no instructions)10 hours57
Time Receipt

Things used in this project

Hardware components

Grove - RTC
Seeed Grove - RTC
×1
Seeeduino Lotus V1.1 - ATMega328 Board with Grove Interface
Seeeduino Lotus V1.1 - ATMega328 Board with Grove Interface
×1
Grove - Speaker
Seeed Grove - Speaker
×1
Grove - Ultrasonic Ranger
Seeed Grove - Ultrasonic Ranger
×1
Thermal Printer- Generic
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Custom parts and enclosures

_N9gCDWorHj.dxf

Code

Time Receipt

Arduino
#include <SoftwareSerial.h>
#include <DS1307.h>
#include <Ultrasonic.h>
#include <FlexiTimer2.h>
DS1307 clock;//define a object of DS1307 class

SoftwareSerial mp3(8, 9); // RX, TX
Ultrasonic ultrasonic0(2);

long mp3_time = 0;
int date_flag = 0;

int per_min = 0;

int times = 0;

unsigned char mp3Hex_play1[6] {0xAA, 0x07, 0x02, 0x00, 0x01, 0xB4};
unsigned char mp3Hex_VOLUME[5] {0xAA, 0x13, 0x01, 0x16, 0xD4};
void Print()
{
  if(date_flag == 0)
  {
    Serial.println("________________________________");
    Serial.println("TIME         QTY          AMOUNT");
    Serial.println("--------------------------------");
    per_min = clock.minute;
    date_flag = 1;
  }
  if(clock.minute - per_min >= 1)
  {
    Serial.print(clock.hour, DEC);
    Serial.print(":");
    Serial.print(clock.minute, DEC);
    Serial.print(":");
    Serial.print(clock.second, DEC);
    Serial.print("      1       Priceless");
    Serial.println();
    ++times;
    per_min = clock.minute;
  }else if(ultrasonic0.RangeInCentimeters <= 10)
  {
    Serial.print(clock.hour, DEC);
    Serial.print(":");
    Serial.print(clock.minute, DEC);
    Serial.print(":");
    Serial.print(clock.second, DEC);
    Serial.print("      1       Priceless");
    Serial.println();
    ++times;
  }
  if(times == 30)
  {
    Serial.println("________________________________");
    Serial.println("TIME         QTY          AMOUNT");
    Serial.println("--------------------------------");
    times = 0;
  }
}

void MP3()
{
  if(mp3_time != 0)
  {
    if(millis() - mp3_time >= 7500)
    {
      mp3_time = millis();
      mp3.write(mp3Hex_play1, 6);
      delay(500);
    }
  }else
  {
    mp3_time = millis();
    mp3.write(mp3Hex_play1, 6);
    delay(500);
  }
}

void setup() {
  Serial.begin(9600);
  clock.begin();
  mp3.begin(9600);
  mp3.write(mp3Hex_VOLUME, 5);
  FlexiTimer2::set(1000, 1.0/1000, Print);
  FlexiTimer2::start();
}

void loop() {
  clock.getTime();
  ultrasonic0.MeasureInCentimeters();
  if(ultrasonic0.RangeInCentimeters <= 10)
  {
    MP3();
  }
}

Credits

chen yiwen

chen yiwen

1 project • 0 followers

Comments

Add projectSign up / Login