Ingo Lohs
Published © GPL3+

Clock - Grove 4-digit Display Using Photon

Your first clock with 4 components, based on Grove and TM1637.

BeginnerShowcase (no instructions)1 hour3,297
Clock - Grove 4-digit Display Using Photon

Things used in this project

Hardware components

Photon
Particle Photon
×1
Seeed Studio Base Shield for Photon
×1
Seeed Studio 4 Digit Display
×1
Seeed Studio Grove - Universal 4 PIN Jumper
1 to connect the Display
×1

Story

Read more

Code

TM1637 presents a clock

C/C++
// tested with Photon, firmware v0.6.1

#include <TM1637Display.h>

#define CLK D4
#define DIO D5

TM1637Display displayTime(CLK,DIO);

void setup() {
    displayTime.setBrightness(0xff); //set the diplay to maximum brightness
//    displayTime.setBrightness(0x0a); //not so bright
    Time.zone(+2.00);  // setup a time zone, which is part of the ISO6801 format 
}



void loop() {
    int h = Time.hour();
    int m = Time.minute();

    // Set center colon on without array - Start
    uint8_t segto;
    int value = 1244;
    segto = 0x80 | displayTime.encodeDigit((value / 100)%10); // And off will be without this 0x80 bit set
    displayTime.setSegments(&segto, 1, 1);
    //delay(1000) ; // constant colon
    // End

    // Print Data array - Start
    uint8_t data[] = {0xff, 0xff, 0xff, 0xff};
    
      data[0] = displayTime.encodeDigit(h / 10);
      data[1] = displayTime.encodeDigit(h % 10) | (Time.second() % 2 ? 0x80 : 0x00);
      data[2] = displayTime.encodeDigit(m / 10);
      data[3] = displayTime.encodeDigit(m % 10);
      displayTime.setSegments(data);

}

Credits

Ingo Lohs

Ingo Lohs

182 projects • 194 followers
I am well over 50 years and come from the middle of Germany.

Comments