Creating a jumping clock

I want to create a clock program that, every time the time ends in a 5, the time will jump by 5 minutes (e.g., one minute after 12:05 the clock jumps to 12:10). How would I go about doing this based on the looping code below? (lander_display refers to the Adafruit 4-digit display I am using) (I am specifically programming the clock not to follow a 60-minute setup or reset at 12:59)

  for (int i = 1200; i < 9999; i++) {
    delay(60000);
    lander_display.showNumberDecEx(i+1, 0b01000000);

you posted a snippet, you get a snippet:

if (tm.tm_min % 5 == 0 && previousMM != tm.tm_min) {
  previousMM = tm.tm_min;
  display.clear();
  display.print(tm.tm_hour);
  display.print(':');
  display.print(tm.tm_min);
}

if it doesn't work for you read

If you still can't get it working - read again chapter 6 bullet 5.

2 Likes

what about only after reaching the 5 min interval does it display that value

int min;

    minDisplay = 5 * (min / 5);
if (!(time%5)) time += 4;
time++; // skip over the 5 multiple
#include "Arduino.h"
#include <TM1637Display.h>

// all_on pins connected to the TM1637 display
const byte CLK_PIN = 6;
const byte DIO_PIN = 5;

// Create display object of type TM1637Display:
TM1637Display lander_display = TM1637Display(CLK_PIN, DIO_PIN);

// Create array that turns all segments on:
const byte all_on[] = { 0b11111111,
                        0b11111111,
                        0b11111111,
                        0b11111111 };


void setup() {
  lander_display.setBrightness(1.5);  // Configure the display brightness (0-7):
// Clear the display (all segments off)
  lander_display.clear();
  delay(1000);
  lander_display.showNumberDecEx(1200, 0b01000000);
  // Sets initial time
}

void loop() {
  for (int i = 1200; i < 9999 ; i++) {
    delay(60000);
    lander_display.showNumberDecEx(i+1, 0b01000000);}
    //Adds 1 to time value every minute
  }

@xfpd That's a long way to go for

    time += 5;

Maybe I don't understand the context of you lines of code.

a7

As I wrote that, I thought; If I add 5, the value might still be a multiple of 5... my long way was to move close to 5, let time move a little farther away from the whole value, then add one more minute to jump over the multiple of 5. I also thought of jumping to 6, then subtracting. Not tested.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.