Adding audio component to Arduino clock

Hello,

I've built my first Arduino project, which is clock with LCD display (I2C converter) and RTC1302 module. Here is the scheme I followed:


I would like to add some audio component, which would make the ticking or beeping sound (hopefully, not too annoying...). I wanted to ask for an advice which components work the best and also where should to add it to my project. Also, if and which transistors would be necessary (that part for a beginner like me is a mystery for now...).

I've considered:
Buzzer (although the simplest, I am wondering if it is possible to make the sound pleasant)
Speaker and DFPlayer with card reader
Grove speaker from Seeeduino (although I'm not sure, I think it requires a shield, so that would be really hard to add to existing parts)

The next part is coding. I was wondering how to sync the beep with the clock, and how to make it silent at a time.
Here is the code I'm using (there are some modifications to the standard clock code)

#include "virtuabotixRTC.h"//Library used
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);
virtuabotixRTC myRTC(2, 3, 4); //The order here is DAT,CLK,RST. You can change this depending on the wiring

char timeChar [8]; //number of digits for the format
uint8_t prevSeconds = 0; //

void setup() 
{
  
  Serial.begin(9600);
  
  lcd.init();
  lcd.backlight();
  
  // Set the current date, and time in the following format:
  // seconds, minutes, hours, day of the week, day of the month, month, year
  //myRTC.setDS1302Time(30, 21, 00, 5, 07, 01, 2021); //Here you write your actual time/date as shown above
  //but remember to "comment/remove" this function once you're done
  //The setup is done only one time and the module will continue counting it automatically
}
void loop() 
{
  
  myRTC.updateTime();
  
  if(myRTC.seconds != prevSeconds)  // Only update display if seconds have changed
  {
    prevSeconds = myRTC.seconds;
    
    // Start printing elements as individuals
    
    if(myRTC.seconds %10)
    {
      sprintf(timeChar, "%02d:%02d:%02d",myRTC.hours, myRTC.minutes, myRTC.seconds);
      if(myRTC.seconds == 9 || myRTC.seconds == 19 || myRTC.seconds == 29 || myRTC.seconds == 39 || myRTC.seconds == 49 || myRTC.seconds == 59)
      {
        // timeChar[0] = 'Z';
        // timeChar[4] = 'X';
        timeChar[0] = random("32, 128");
        timeChar[4] = random("32, 128");
      }
    }
    else
    {
      sprintf(timeChar, "D0:0M:%02d", myRTC.seconds);
    }
    
    lcd.print(timeChar);
  }

Thanks in advance and best regards,
Lena

Before adding anything new make a test code exercising one new device at the time. This way trouble shooting is a loth less time consuming, a lot less frustrating. When one new device is running, integrate the needed new code in the main project, one at the time. Trouble shooting again...
Physically, mount the components where there is place. Speakers, buzzer preferably behind a hole in the box.
Logically, add necessary code at the end of setup resp. loop().

If You drop that type of toy picture, that coloured bird nest, You will get a lot more respect. That thing is stone dead, no power supplied. Power issues are way too often the reason for problems. Therefore every helper appreciates looking at real schematics showing pin designations, power supplies and their rating.

Back around here, you know a second has elapsed…
It’s a good point to add your tick function call.

That code will depend on what you’re using as a sounder.
Maybe as simple as a transistor and a relay, so it goes ‘tick’ once per second !

In all its simplicity it's a genius way to generate a stable "klick".

‘tick’ vs ‘klick’ ? :doughnut::scream_cat:

I’ll leave that to the argumentative types ! @GolamMostafa, are you listening ?

Very much!

:rainbow::+1::sunglasses:

Why? :grimacing:

Ohhh, sorry, I made some mistakes. I want to post a proper circuit diagram and I'm working on it :slight_smile:

Oh, I really like that idea. The sound would be perfect. Don't know where to join it yet - beginner struggles. Also, I should have mentioned that the whole project is powered by power bank plugged to USB cord, as I needed something easily removable. Therefore - 5V I guess. The advice on where can I add the relay and a transistor, so it would make a ticking sound, would be highly appreciated. I'm going to try to post the circut scheme also.

You can use 'Speaker and DFPlayer with card reader' for a short melody every hour. Maybe it would be good to turn off all these sound effects from 22:00 to 08:00, for example, so as not to interfere with the night's sleep.

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