Need help with LED clock - new to Arduino

PaulRB:
Have a look at this. The important bits are at the bottom of the schematic. That wierd-looking diode is the answer to part of your question. Its called a Zener diode.

No, it is called a Schottky diode, and it functions completely differently than a Zener.

jeredneus:
It informs me I have to wait 5 minutes before sending another post. Any ideas on how I can avoid this problem?

You have to attain a certain number of posts. Your circuit layout looks plausible, I can't fault that although I'm only looking at the front in the images. You seem to be on the right track.

I didn't show a picture of the back of the PCB since all there is visible are a few wires (connecting the modules to the power regulator board) and the solder joints on the pins of the modules attached to the board.

So now, on to the next part. Connecting the LED matrix to the HT16K33 module. I have 9 anode leads and six cathode leads; is the matrix scanned from left to right, or right to left? I don't want to connect it in the wrong order. Then finally adding the push buttons to set the time.

After these steps are completed, then comes the really hard part (for me, at least), and that is the code to turn the assembly of parts into a working clock that displays time in 12-hour format. Right now, the DS3231 module is displaying time in 24 hour format. I understand the module can display time in 12 hour format, it needs to be done in the code that addresses the module.

Why 12 hour mode? Because I am used to seeing clocks that display time in 12 hour format; I also would like the display to show a leading zero in the hours between 1 and 9.

is the matrix scanned from left to right, or right to left? I don't want to connect it in the wrong order.

The scanning is too fast for the eye to see. If you mean what address/register numbers control each anode/cathode, again it does not really matter because that can be compensated for in the code, but i suggest you use the lower anode & cathode numbered pins, in top-bottom & left-right order.

Converting 24 to 12 hour format and adding leading zeroes is all simple to do in code.

aarg:
No, it is called a Schottky diode, and it functions completely differently than a Zener.

Sorry! I meant Schottky!

Before you go any further, give this sketch a try.

i2c scanner

You should see two devices reported by the sketch: the rtc and the led driver.

Thanks for the info Paul. I will try out the sketch.

PaulRB:
i suggest you use the lower anode & cathode numbered pins, in top-bottom & left-right order.

Just to be sure, you are referring to the pins on the HT16K33 module?

I will need to find out which pin or pins are used to connect the buttons for setting the clock. Unless it would be simpler to connect them to the Nano.

Ok, I ran the sketch that you suggested, and it listed three device addresses; 0x57, 0x68 and 0x70. The second address is for the DS3231 and the third is for the HT16K33. So is the first address the Nano board?

jeredneus:
Just to be sure, you are referring to the pins on the HT16K33 module?

The pin names on the module just mirror the pin names on the IC.

jeredneus:
Ok, I ran the sketch that you suggested, and it listed three device addresses; 0x57, 0x68 and 0x70. The second address is for the DS3231 and the third is for the HT16K33. So is the first address the Nano board?

Ahh, yes, I was forgetting something. I have some of those same DS3231 modules you have. They also contain an eeprom chip, that's what address 0x57 is. You probably won't have any use for it in this project and can ignore it.

Project update:

I have connected the anode and cathode leads from the LED matrix to a special connector I built that will attach to the pins on the HT16K33 from the back of the PCB; that way I can test the matrix without making any permanent connections in case there are any problems.

I also made a connector for the leads from the LED string that forms rows 4 and 5 of the display; these LEDs stay on all the time.

So far, everything seems to be working as expected. The LED string lights up just fine. The components on the PCB (Nano, DS3231 and HT16K33) are found on the I2C line using the script that looks for any device connected to it. (Thanks, Paul). The DS3231 is keeping time.

The final test is to see if the LEDs that are connected to the HT16K33 will light up. To do this, I will need a script that tests the HT16K33 pins to see if they are working as they should. If anyone knows where I could find such a script, I would really appreciate it.

Then when everything that is connected together so far is working correctly, the last components to be added will be the buttons to set the clock, so I won't have to connect the Nano to my computer every time I need to update the time.

Side note; so far, the circuit works whether it is powered through the Nano's USB port, or through the barrel jack on the voltage regulator.

jeredneus:
The final test is to see if the LEDs that are connected to the HT16K33 will light up. To do this, I will need a script that tests the HT16K33 pins to see if they are working as they should. If anyone knows where I could find such a script, I would really appreciate it.

There are no scripts in Arduino, only code, libraries and sketches.

If you don't have an HT16K33 library, you really need to get one now. It will have example sketches to drive the LEDs.

aarg:
There are no scripts in Arduino, only code, libraries and sketches.

Sorry, I meant sketch and not script. Sometimes the fingers work faster than the brain. Thanks for the tip.

Update #2;

SUCCESS!! The LED matrix works! I found the library that you mentioned, aarg, and installed it into the directory that contains the Arduino IDE program. I found an example sketch called '16x8 matrix', and uploaded it to the Nano. All the LEDs on the matrix light up in various patterns ( I can't see the full patterns since my matrix is 3x18, and the text and graphics are being split up into three sections (it is wired as a 6x9 matrix, but laid out as a 3x18 matrix physically).

I am trying to find the part of the code that controls the brightness of the LEDs; the HT16K33 supports 16 levels of brightness, and they are currently not bright enough to match the LEDs that are separately powered.

#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"

Adafruit_8x16matrix matrix = Adafruit_8x16matrix();

void setup() {
  Serial.begin(9600);
  Serial.println("16x8 LED Matrix Test");
  
  matrix.begin(0x70);  // pass in the address
}

static const uint8_t PROGMEM
  smile_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10100101,
    B10011001,
    B01000010,
    B00111100 },
  neutral_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10111101,
    B10000001,
    B01000010,
    B00111100 },
  frown_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10011001,
    B10100101,
    B01000010,
    B00111100 };

void loop() {
  
  matrix.clear();
  matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
  matrix.writeDisplay();
  delay(500);
  
  matrix.clear();
  matrix.drawBitmap(0, 8, neutral_bmp, 8, 8, LED_ON);
  matrix.writeDisplay();
  delay(500);

  matrix.clear();
  matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_ON);
  matrix.writeDisplay();
  delay(500);

  matrix.clear();      // clear display
  matrix.drawPixel(0, 0, LED_ON);  
  matrix.writeDisplay();  // write the changes we just made to the display
  delay(500);

  matrix.clear();
  matrix.drawLine(0,0, 7,15, LED_ON);
  matrix.writeDisplay();  // write the changes we just made to the display
  delay(500);

  matrix.clear();
  matrix.drawRect(0,0, 8,16, LED_ON);
  matrix.fillRect(2,2, 4,12, LED_ON);
  matrix.writeDisplay();  // write the changes we just made to the display
  delay(500);

  matrix.clear();
  matrix.drawCircle(3,8, 3, LED_ON);
  matrix.writeDisplay();  // write the changes we just made to the display
  delay(500);

  matrix.setTextSize(2);
  matrix.setTextWrap(false);  // we dont want text to wrap so it scrolls nicely
  matrix.setTextColor(LED_ON);
  for (int8_t x=0; x>=-64; x--) {
    matrix.clear();
    matrix.setCursor(x,0);
    matrix.print("Hello");
    matrix.writeDisplay();
    delay(100);
  }

  matrix.setTextSize(1);
  matrix.setTextWrap(false);  // we dont want text to wrap so it scrolls nicely
  matrix.setTextColor(LED_ON);
  matrix.setRotation(1);
  for (int8_t x=7; x>=-36; x--) {
    matrix.clear();
    matrix.setCursor(x,0);
    matrix.print("World");
    matrix.writeDisplay();
    delay(100);
  }
  matrix.setRotation(0);
}

So all that is left on the hardware side is to hook up the buttons to set the clock. I have a 1x4 Membrane keypad that I would like to use; it has a common input pin and four separate output pins. I assume that the common pin could be either positive or negative, depending on how the keypad is connected to the circuit.

Update #3:

Looks like I was a little premature on my success proclamation. The circuit works correctly when the power is coming in through the Nano USB port; I had the USB cable connected to upload the sketch to the Nano to test the LED matrix, and everything went smoothly; the LEDs on the matrix all worked, though dimmer than I would like; the LEDs on the separate string all lit up fine; everything was going great.

However, when I disconnected the USB cable and connected the DC adapter to the circuit through the voltage regulator, there was a problem with the LEDs in the matrix. They still lit up as before, but now if the pattern displayed on the matrix stopped moving, the LEDs would visibly flicker. The pattern itself was not affected. The separate LED string was not affected either, nor was the power LEDs on the other modules. Any idea what the problem might be?

Try:

matrix.setBrightness(15);

Although i suspect it defaults to this anyway. Can you increase the series resistors for the fixed leds? Or wire them to the controller also? The advantage of wiring them to the controller would be that you could dim them with the rest of the display, should you decide to add an ldr to the circuit to atoltomatically adjust the brightness in a dim/dark room.

Use a multimeter to check the voltage coming out of that regulator module when the leds are flickering.

Where do I insert the line of code?

As to the fixed LEDs, they are wired in parallel with a single resistor on the anode of the first LED in the string. I used a resistor calculator to determine the value to use (3.3 ohm 2W for 28 white LEDs). The LEDs in the matrix are too dim to be clearly visible in a daylit room; they would be OK in a low light room.

I checked the pinouts on the voltage regulator; with the DC adapter plugged in the barrel jack, the pins read around 4.25V. When I plug in the USB cable to the Nano (after disconnecting the DC adapter) and check the pins on the voltage regulator again, the voltage drops to about 3.2V. The brightness on the LEDs remain the same when powered either way. The only difference is the flickering of the matrix LEDs when the voltage regulator is used to power the circuit. It doesn't seem to affect anything else in the circuit.

I am currently running the circuit connected via the USB cable; I will leave it on for awhile to make sure there aren't any other problems that haven't appeared yet.

When you say to wire the fixed LED string to the controller, do you mean the Nano, or the HT16K33? I plugged the fixed LED string into the Nano directly, using the 5V and GND pins on the ICSP header, and the brightness was the same. If the LEDs in the matrix can't be made any brighter, then I guess I'll have to dim the LED string to match the matrix.

I found the solution to the power problem quite by accident. I had already replaced the 9V DC adapter I was originally using with another 9V DC adapter I had on hand. The original adapter was causing the fixed string of LEDs to flicker (this was before I had connected the LED matrix). I didn't have this problem with the second adapter, but when I connected the matrix to the circuit, it was causing the LEDs in the matrix to flicker. So I decided, what the heck, I would connect a 5V DC adapter that had a USB to DC barrel cable to supply power to the voltage regulator. Problems with the LEDs went away; no more flickering. So now all I need to do is replace the resistor on the LED string so they will be the same as the LEDs in the matrix. I found out that you were right about the HT16K33; the default is the brightest output for the LEDs, so no way to make them brighter.

That leaves me with the option of redoing the front of the display; removing the tinted film and replacing it with something that doesn't block as much light, as well as the diffusion material under it. Hopefully that will solve the brightness issue.

Finished rebuilding the LED matrix; wiring all of the LEDs in the display into the matrix in order to achieve uniform brightness. It turned out even better than the original; used a different batch of white LEDs, had to replace the HT16K33 module due to damage trying to remove it from the PCB, and used solid core wire to connect the anode and cathode leads from the matrix to the adapter I built to plug into the pins on the underside of the PCB for the HT16K33. The result was a brighter output from the LEDs, so I can still use the same material on the front for light diffusion and tinting.

It would seem that either the Adafruit HT16K33 module or the LEDs were the problem; since I only had one of the Adafruit modules and used one of the clone modules I purchased on eBay to replace it, and the white LEDs in the original matrix came from a batch of 100 LEDs I had purchased a while ago and didn't have enough left from it, so I used a different batch of 100 LEDs I had purchased as a backup in case something like this (rebuilding the matrix) became necessary. Sooooo... long story short, both or either replacement solved the problem.

On to the next step; the buttons for setting the time. Then the code to make it work as a clock.