li jinhao
Published

Mischievous Time

For this project, the parts I needed are 1 MCU (Seeeduino Lotus), 1 Grove Ultrasonic Sensor, and 1 Grove 4-digit display

BeginnerFull instructions provided10 hours27
Mischievous Time

Things used in this project

Hardware components

Seeeduino Lotus V1.1 - ATMega328 Board with Grove Interface
Seeeduino Lotus V1.1 - ATMega328 Board with Grove Interface
×1
Grove - Ultrasonic Ranger
Seeed Grove - Ultrasonic Ranger
×1
Seeed Grove-4-digit-display
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)
Hand tools

Story

Read more

Custom parts and enclosures

li

Enclosures and custom parts

Schematics

li

Schematics and circuit diagrams

Code

li

Arduino
the control of the project
#include <TimerOne.h>
#include <DS1307.h>
#include "Ultrasonic.h"
#include "TM1637.h"

int8_t TimeDisp[] = {0x00,0x00,0x00,0x00};
unsigned char ClockPoint = 1;
long RangeInCentimeters;

DS1307 clock;
Ultrasonic ultrasonic(6);
#define CLK 2//pins definitions for TM1637 and can be changed to other ports
#define DIO 3
TM1637 tm1637(CLK,DIO);

void TimeUpdate(void)
{
  clock.getTime();
  if(ClockPoint)tm1637.point(POINT_ON);
  else tm1637.point(POINT_OFF);
  TimeDisp[0] = clock.hour / 10;
  TimeDisp[1] = clock.hour % 10;
  TimeDisp[2] = clock.minute / 10;
  TimeDisp[3] = clock.minute % 10;
  tm1637.display(TimeDisp);
}

void TimingISR()
{
  ClockPoint = (~ClockPoint) & 0x01;
}

void setup() {
  Serial.begin(115200);
  clock.begin();
  tm1637.set();
  tm1637.init();
  Timer1.initialize(500000);//timing for 500ms
  Timer1.attachInterrupt(TimingISR);
}

void loop() {
  RangeInCentimeters = ultrasonic.MeasureInCentimeters();
  if(RangeInCentimeters <= 50)
  {
    tm1637.clearDisplay();
    tm1637.point(POINT_OFF);
  }else
  {
    TimeUpdate();
  }
}

Credits

li jinhao

li jinhao

1 project • 0 followers

Comments

Add projectSign up / Login