Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
BlueJay
Published © GPL3+

EASY Arduino Alarm Clock (w/ Matrix Display)

A functioning alarm clock with an easily adjustable alarm time, a matrix display, and a nice case to go with it!

BeginnerFull instructions provided556
EASY Arduino Alarm Clock (w/ Matrix Display)

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Buzzer
Buzzer
×1
DS3231M MEMS Precise RTC
DFRobot DS3231M MEMS Precise RTC
×1
LED Dot Matrix Display, Red
LED Dot Matrix Display, Red
×4

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Optional

Story

Read more

Code

matrix_alarm_clock.ino

C/C++
#include <RTClib.h>
#include <Wire.h>
RTC_DS3231 rtc;
char t[32];

#include "MD_Parola.h"
#include "MD_MAX72xx.h"
#include "SPI.h"

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CS_PIN 5
#define DATA_PIN 6
#define CLK_PIN 4
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

byte BUZZER = 3;

int ALARMHOUR = 16;
int ALARMMINUTE = 07;

void checkAlarm() {
  DateTime now = rtc.now();
  if (now.hour() == ALARMHOUR && now.minute() == ALARMMINUTE || Serial.read() == 'a') {
    tone(BUZZER, 250, 400);
    delay(1000);
    tone(BUZZER, 250, 400);
    delay(1000);
    tone(BUZZER, 250, 400);
    delay(1000);
    tone(BUZZER, 250, 400);
    delay(1000);
  }
}

void debugTime() {
  DateTime now = rtc.now();
  Serial.print(now.hour());
  Serial.print(" ");
  Serial.print(now.twelveHour());
  Serial.print(" ");
  Serial.print(now.minute());
  Serial.print(" ");
  Serial.print(now.second());
  Serial.print(" ");
  Serial.print(now.isPM());
  Serial.println(" ");
}

void setup()
{
  myDisplay.begin();
  myDisplay.setIntensity(0);
  myDisplay.setTextAlignment(PA_CENTER);
  myDisplay.setCharSpacing(1);
  myDisplay.displayClear();

  Serial.begin(9600);

  Wire.begin();
  rtc.begin();
  rtc.adjust(DateTime(F(__DATE__),F(__TIME__)));

  if (rtc.lostPower()) {
    Serial.println("rtc.lostpower");
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
}
void loop()
{
  DateTime now = rtc.now();
  sprintf(t, "%02d:%02d", now.twelveHour(), now.minute());  
  myDisplay.print(t);
  Serial.println(t);
  Serial.println(now.timestamp(DateTime::TIMESTAMP_FULL));
  checkAlarm();
  //debugTime();
  delay(1000);
}

GitHub

Credits

BlueJay

BlueJay

4 projects • 2 followers
a guy who makes stuff :D been tinkering with arduino for some time, and am starting to get more advanced ^_^

Comments