Trying to make a countdown/clock

hello I need some ideas to how to make a countdown/clock with this code I made.

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

#define PIN 6

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
  NEO_MATRIX_TOP    + NEO_MATRIX_LEFT +
  NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  NEO_GRB            + NEO_KHZ800);

int colorRED = matrix.Color(255, 0, 0);

void setup() {
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(60);
  matrix.setTextColor(colorRED);
}

void loop() {
  matrix.fillScreen(0); 
  matrix.setCursor(1, 0);
  matrix.print(F("00:00"));
  matrix.show();  
  }

Work on that bit first.

Please remember to use code tags when posting code.

this is my first time posting a code so I will look into that, thanks

yeah remember it
:worried:

I don't understand your reply.

Here are some things for you to think about:

How long a countdown do you want? One minute? Five minutes? An hour? Or do you want to be able to select the length of time you want, using buttons or switches or something?

How will you actually count the time, and calculate the length of time remaining? You will probably need to declare some variables for that.

How will you print the length of time remaining (a variable number) onto the display? How will you get the leading zero in front of numbers less than ten? (for example, :09 for nine seconds)

Here is a count-up stopwatch which I have coded, and which you might want to use for ideas:

I know, the Wokwi demo does not run at the correct speed, but you can still use it to see how the sketch works.

thinking of a timer that goes from 1 hour and down, its going to be a timer for a escape room on a ws8212b 8x32 or LCD for a school project. If I can find it maybe I will use a esp8266 or something like that to sync or just make variables havent made up my mind yet.

I'd make a sketch that just uses the serial monitor to display your count.
You'll need to know when a second has passed, using millis() not delay(), and make changes to one or more variables, then print them to the serial monitor.
Once you've got that worked out then go back to setting up your LEDs.

#include <LiquidCrystal.h> 
const uint32_t MICROS_PER_TENTH = 100000UL;
 uint32_t microsAtLastTenth = 0UL;
 uint16_t days=0;
 uint8_t hours=0, minutes=0, seconds=0, tenths=0;
 bool countTime = false;
 const uint8_t START_PIN = 2;
 const uint8_t RESET_PIN = 3;
 uint8_t previousState = HIGH;
 char buf[20];
 LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
 void setup()
 {
 lcd.begin(16, 2);
 pinMode(START_PIN, INPUT_PULLUP);
 pinMode(RESET_PIN, INPUT_PULLUP);
 } 

void loop() { // deal with start/stop button …

I mean that I remember It's like that just I didn't post it on here.

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