使用Arduino的大型实时时钟的制作

电子说

1.3w人已加入

描述

步骤1:

使用p10 Matrix Display和DS3231 RTC时钟。

硬件:

Arduino Uno x 1

按钮(键盘)x 4

RTC模块(DS3231)

P10点矩阵显示

软件:

Arduino IDE

DMD 2库/DMD库

在此之前,您需要一个必须在Arduino IDE上安装的支持库。要下载上面提到的DMD2库

步骤2:连接

时钟

时钟

* Arduino-》 RTC模块*

A4-》 SDA

A5-》 SCL

VCC-》 5V

GND-》 GND

* Arduino-》 P10 DMD *

D8-》 SCK

D6-》 A

D7- 》 B

D11-》 R

D13-》 CLK

D9-》 OE

第3步:代码

You can find the sample code below.

//使用Arduino的Chakra Healing Harmonizer

/*访问Channel以获得更有趣的信息项目https://www.youtube.com/channel/UCks-9JSnVb22dlqt.。.*/

byte dayOfWeek=4;

byte dayOfMonth=1;#include //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)

#include //

#include //

#include “Wendy3x5.h”

#include “Wire.h”

#define DS1307_I2C_ADDRESS 0x68int AlarmSetPin = 2;

int SnoozePin = 3;

int Alarm = 4;

int AlarmSet = 0;

int Snooze = 0;

int a,b;

// Convert normal decimal numbers to binary coded decimal

byte decToBcd(byte val)

{

return ( (val/10*16) + (val%10) );

}// Convert binary coded decimal to normal decimal numbers

byte bcdToDec(byte val)

{

return ( (val/16*10) + (val%16) );

}// 1) Sets the date and time on the ds1307

// 2) Starts the clock

// 3) Sets hour mode to 24 hour clock// Assumes you‘re passing in valid numbersvoid setDateDs1307(byte second, // 0-59

byte minute, // 0-59

byte hour, // 1-23

byte dayOfWeek, // 1-7

byte dayOfMonth, // 1-28/29/30/31

byte month, // 1-12

byte year) // 0-99

{

Wire.beginTransmission(DS1307_I2C_ADDRESS);

Wire.write(0);

Wire.write(decToBcd(second)); // 0 to bit 7 starts the clock

Wire.write(decToBcd(minute));

Wire.write(decToBcd(hour));

Wire.write(decToBcd(dayOfWeek));

Wire.write(decToBcd(dayOfMonth));

Wire.write(decToBcd(month));

Wire.write(decToBcd(year));

Wire.write(00010000); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave

Wire.endTransmission();

}// Gets the date and time from the ds1307

void getDateDs1307(byte *second,

byte *minute,

byte *hour,

byte *dayOfWeek,

byte *dayOfMonth,

byte *month,

byte *year)

{

// Reset the register pointer

Wire.beginTransmission(DS1307_I2C_ADDRESS);

Wire.write(0);

Wire.endTransmission();

Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

}//Fire up the DMD library as dmd

DMD dmd(1,1);void ScanDMD()

{

dmd.scanDisplayBySPI();

}void setup()

{

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; //initialize TimerOne’s interrupt/CPU usage used to scan and refresh the display

Timer1.initialize( 5000 ); //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.

Timer1.attachInterrupt( ScanDMD ); //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI() //clear/init the DMD pixels held in RAM

dmd.clearScreen( true ); //true is normal (all pixels off), false is negative (all pixels on)

dmd.selectFont(Wendy3x5 ); Wire.begin(); // Change these values to what you want to set your clock to.

// You probably only want to set your clock once and then remove

// the setDateDs1307 call. second = 0;

minute = 35;

hour = 11; // use 24-hour time otherwise day/date calculations will be off

dayOfWeek = 1;

dayOfMonth = 23;

month = 3;

year = 14;

//uncomment the setDateDs1307 call below to set time to intervals above. Remember if you set the time

//you need to uncomment the line below again otherwise the sketch will only stay at the time set.

//setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year); pinMode(AlarmSetPin, INPUT_PULLUP);

pinMode(SnoozePin, INPUT_PULLUP);

pinMode(Alarm, OUTPUT);

digitalWrite(Alarm, LOW);

}void drawDay()

// shows day of week

{

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

switch(dayOfWeek)

{

case 1:

dmd.drawString( 1,0, “Sun,”, 3, GRAPHICS_NORMAL );

break; case 2:

dmd.drawString( 1,0, “Mon,”, 3, GRAPHICS_NORMAL );

break; case 3:

dmd.drawString( 1,0, “Tue,”, 3, GRAPHICS_NORMAL );

break; case 4:

dmd.drawString( 1,0, “Wed,”, 3, GRAPHICS_NORMAL );

break; case 5:

dmd.drawString( 1,0, “Thu,”, 3, GRAPHICS_NORMAL );

break; case 6:

dmd.drawString( 1,0, “Fri,”, 3, GRAPHICS_NORMAL );

break; case 7:

dmd.drawString( 1,0, “Sat,”, 3, GRAPHICS_NORMAL );

break;

}

}void drawDate()

// shows numerical date

{

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

switch(dayOfMonth)

{

case 1:

dmd.drawString( 20,0, “01”, 2, GRAPHICS_NORMAL );

break;

case 2:

dmd.drawString( 20,0, “02”, 2, GRAPHICS_NORMAL );

break;

case 3:

dmd.drawString( 20,0, “03”, 2, GRAPHICS_NORMAL );

break;

case 4:

dmd.drawString( 20,0, “04”, 2, GRAPHICS_NORMAL );

break;

case 5:

dmd.drawString( 20,0, “05”, 2, GRAPHICS_NORMAL );

break;

case 6:

dmd.drawString( 20,0, “06”, 2, GRAPHICS_NORMAL );

break;

case 7:

dmd.drawString( 20,0, “07”, 2, GRAPHICS_NORMAL );

break;

case 8:

dmd.drawString( 20,0, “08”, 2, GRAPHICS_NORMAL );

break;

case 9:

dmd.drawString( 20,0, “09”, 2, GRAPHICS_NORMAL );

break;

case 10:

dmd.drawString( 20,0, “10”, 2, GRAPHICS_NORMAL );

break;

case 11:

dmd.drawString( 20,0, “11”, 2, GRAPHICS_NORMAL );

break;

case 12:

dmd.drawString( 20,0, “12”, 2, GRAPHICS_NORMAL );

break;

case 13:

dmd.drawString( 20,0, “13”, 2, GRAPHICS_NORMAL );

break;

case 14:

dmd.drawString( 20,0, “14”, 2, GRAPHICS_NORMAL );

break;

case 15:

dmd.drawString( 20,0, “15”, 2, GRAPHICS_NORMAL );

break;

case 16:

dmd.drawString( 20,0, “16”, 2, GRAPHICS_NORMAL );

break;

case 17:

dmd.drawString( 20,0, “17”, 2, GRAPHICS_NORMAL );

break;

case 18:

dmd.drawString( 20,0, “18”, 2, GRAPHICS_NORMAL );

break;

case 19:

dmd.drawString( 20,0, “19”, 2, GRAPHICS_NORMAL );

break;

case 20:

dmd.drawString( 20,0, “20”, 2, GRAPHICS_NORMAL );

break;

case 21:

dmd.drawString( 20,0, “21”, 2, GRAPHICS_NORMAL );

break;

case 22:

dmd.drawString( 20,0, “22”, 2, GRAPHICS_NORMAL );

break;

case 23:

dmd.drawString( 20,0, “23”, 2, GRAPHICS_NORMAL );

break;

case 24:

dmd.drawString( 20,0, “24”, 2, GRAPHICS_NORMAL );

break;

case 25:

dmd.drawString( 20,0, “25”, 2, GRAPHICS_NORMAL );

break;

case 26:

dmd.drawString( 20,0, “26”, 2, GRAPHICS_NORMAL );

break;

case 27:

dmd.drawString( 20,0, “27”, 2, GRAPHICS_NORMAL );

break;

case 28:

dmd.drawString( 20,0, “28”, 2, GRAPHICS_NORMAL );

break;

case 29:

dmd.drawString( 20,0, “29”, 2, GRAPHICS_NORMAL );

break;

case 30:

dmd.drawString( 20,0, “30”, 2, GRAPHICS_NORMAL );

break;

case 31:

dmd.drawString( 20,0, “31”, 2, GRAPHICS_NORMAL );

break;

}

}void drawHour()

// draws the hour hand

{

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

if (hour》12) //Remove this if command for 24 hour time

{

hour=hour-12; // This is a 12 hour Clock

}

switch(hour)

{

case 1:

dmd.drawString( 0,0, “01”, 2, GRAPHICS_NORMAL );

break;

case 2:

dmd.drawString( 0,0, “02”, 2, GRAPHICS_NORMAL );

break;

case 3:

dmd.drawString( 0,0, “03”, 2, GRAPHICS_NORMAL );

break;

case 4:

dmd.drawString( 0,0, “04”, 2, GRAPHICS_NORMAL );

break;

case 5:

dmd.drawString( 0,0, “05”, 2, GRAPHICS_NORMAL );

break;

case 6:

dmd.drawString( 0,0, “06”, 2, GRAPHICS_NORMAL );

break;

case 7:

dmd.drawString( 0,0, “07”, 2, GRAPHICS_NORMAL );

break;

case 8:

dmd.drawString( 0,0, “08”, 2, GRAPHICS_NORMAL );

break;

case 9:

dmd.drawString( 0,0, “09”, 2, GRAPHICS_NORMAL );

break;

case 10:

dmd.drawString( 0,0, “10”, 2, GRAPHICS_NORMAL );

break;

case 11:

dmd.drawString( 0,0, “11”, 2, GRAPHICS_NORMAL );

break;

case 12:

dmd.drawString( 0,0, “12”, 2, GRAPHICS_NORMAL );

break;

case 13:

dmd.drawString( 0,0, “13”, 2, GRAPHICS_NORMAL );

break;

case 14:

dmd.drawString( 0,0, “14”, 2, GRAPHICS_NORMAL );

break;

case 15:

dmd.drawString( 0,0, “15”, 2, GRAPHICS_NORMAL );

break;

case 16:

dmd.drawString( 0,0, “16”, 2, GRAPHICS_NORMAL );

break;

case 17:

dmd.drawString( 0,0, “17”, 2, GRAPHICS_NORMAL );

break;

case 18:

dmd.drawString( 0,0, “18”, 2, GRAPHICS_NORMAL );

break;

case 19:

dmd.drawString( 0,0, “19”, 2, GRAPHICS_NORMAL );

break;

case 20:

dmd.drawString( 0,0, “20”, 2, GRAPHICS_NORMAL );

break;

case 21:

dmd.drawString( 0,0, “21”, 2, GRAPHICS_NORMAL );

break;

case 22:

dmd.drawString( 0,0, “22”, 2, GRAPHICS_NORMAL );

break;

case 23:

dmd.drawString( 0,0, “23”, 2, GRAPHICS_NORMAL );

break;

case 24:

dmd.drawString( 0,0, “24”, 2, GRAPHICS_NORMAL );

break;

}

}void drawMinute()

{

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

switch(minute)

{

case 0:

dmd.drawString( 12,0, “00”, 2, GRAPHICS_NORMAL );

break;

case 1:

dmd.drawString( 12,0, “01”, 2, GRAPHICS_NORMAL );

break;

case 2:

dmd.drawString( 12,0, “02”, 2, GRAPHICS_NORMAL );

break;

case 3:

dmd.drawString( 12,0, “03”, 2, GRAPHICS_NORMAL );

break;

case 4:

dmd.drawString( 12,0, “04”, 2, GRAPHICS_NORMAL );

break;

case 5:

dmd.drawString( 12,0, “05”, 2, GRAPHICS_NORMAL );

break;

case 6:

dmd.drawString( 12,0, “06”, 2, GRAPHICS_NORMAL );

break;

case 7:

dmd.drawString( 12,0, “07”, 2, GRAPHICS_NORMAL );

break;

case 8:

dmd.drawString( 12,0, “08”, 2, GRAPHICS_NORMAL );

break;

case 9:

dmd.drawString( 12,0, “09”, 2, GRAPHICS_NORMAL );

break;

case 10:

dmd.drawString( 12,0, “10”, 2, GRAPHICS_NORMAL );

break;

case 11:

dmd.drawString( 12,0, “11”, 2, GRAPHICS_NORMAL );

break;

case 12:

dmd.drawString( 12,0, “12”, 2, GRAPHICS_NORMAL );

break;

case 13:

dmd.drawString( 12,0, “13”, 2, GRAPHICS_NORMAL );

break;

case 14:

dmd.drawString( 12,0, “14”, 2, GRAPHICS_NORMAL );

break;

case 15:

dmd.drawString( 12,0, “15”, 2, GRAPHICS_NORMAL );

break;

case 16:

dmd.drawString( 12,0, “16”, 2, GRAPHICS_NORMAL );

break;

case 17:

dmd.drawString( 12,0, “17”, 2, GRAPHICS_NORMAL );

break;

case 18:

dmd.drawString( 12,0, “18”, 2, GRAPHICS_NORMAL );

break;

case 19:

dmd.drawString( 12,0, “19”, 2, GRAPHICS_NORMAL );

break;

case 20:

dmd.drawString( 12,0, “20”, 2, GRAPHICS_NORMAL );

break;

case 21:

dmd.drawString( 12,0, “21”, 2, GRAPHICS_NORMAL );

break;

case 22:

dmd.drawString( 12,0, “22”, 2, GRAPHICS_NORMAL );

break;

case 23:

dmd.drawString( 12,0, “23”, 2, GRAPHICS_NORMAL );

break;

case 24:

dmd.drawString( 12,0, “24”, 2, GRAPHICS_NORMAL );

break;

case 25:

dmd.drawString( 12,0, “25”, 2, GRAPHICS_NORMAL );

break;

case 26:

dmd.drawString( 12,0, “26”, 2, GRAPHICS_NORMAL );

break;

case 27:

dmd.drawString( 12,0, “27”, 2, GRAPHICS_NORMAL );

break;

case 28:

dmd.drawString( 12,0, “28”, 2, GRAPHICS_NORMAL );

break;

case 29:

dmd.drawString( 12,0, “29”, 2, GRAPHICS_NORMAL );

break;

case 30:

dmd.drawString( 12,0, “30”, 2, GRAPHICS_NORMAL );

break;

case 31:

dmd.drawString( 12,0, “31”, 2, GRAPHICS_NORMAL );

break;

case 32:

dmd.drawString( 12,0, “32”, 2, GRAPHICS_NORMAL );

break;

case 33:

dmd.drawString( 12,0, “33”, 2, GRAPHICS_NORMAL );

break;

case 34:

dmd.drawString( 12,0, “34”, 2, GRAPHICS_NORMAL );

break;

case 35:

dmd.drawString( 12,0, “35”, 2, GRAPHICS_NORMAL );

break;

case 36:

dmd.drawString( 12,0, “36”, 2, GRAPHICS_NORMAL );

break;

case 37:

dmd.drawString( 12,0, “37”, 2, GRAPHICS_NORMAL );

break;

case 38:

dmd.drawString( 12,0, “38”, 2, GRAPHICS_NORMAL );

break;

case 39:

dmd.drawString( 12,0, “39”, 2, GRAPHICS_NORMAL );

break;

case 40:

dmd.drawString( 12,0, “40”, 2, GRAPHICS_NORMAL );

break;

case 41:

dmd.drawString( 12,0, “41”, 2, GRAPHICS_NORMAL );

break;

case 42:

dmd.drawString( 12,0, “42”, 2, GRAPHICS_NORMAL );

break;

case 43:

dmd.drawString( 12,0, “43”, 2, GRAPHICS_NORMAL );

break;

case 44:

dmd.drawString( 12,0, “44”, 2, GRAPHICS_NORMAL );

break;

case 45:

dmd.drawString( 12,0, “45”, 2, GRAPHICS_NORMAL );

break;

case 46:

dmd.drawString( 12,0, “46”, 2, GRAPHICS_NORMAL );

break;

case 47:

dmd.drawString( 12,0, “47”, 2, GRAPHICS_NORMAL );

break;

case 48:

dmd.drawString( 12,0, “48”, 2, GRAPHICS_NORMAL );

break;

case 49:

dmd.drawString( 12,0, “49”, 2, GRAPHICS_NORMAL );

break;

case 50:

dmd.drawString( 12,0, “50”, 2, GRAPHICS_NORMAL );

break;

case 51:

dmd.drawString( 12,0, “51”, 2, GRAPHICS_NORMAL );

break;

case 52:

dmd.drawString( 12,0, “52”, 2, GRAPHICS_NORMAL );

break;

case 53:

dmd.drawString( 12,0, “53”, 2, GRAPHICS_NORMAL );

break;

case 54:

dmd.drawString( 12,0, “54”, 2, GRAPHICS_NORMAL );

break;

case 55:

dmd.drawString( 12,0, “55”, 2, GRAPHICS_NORMAL );

break;

case 56:

dmd.drawString( 12,0, “56”, 2, GRAPHICS_NORMAL );

break;

case 57:

dmd.drawString( 12,0, “57”, 2, GRAPHICS_NORMAL );

break;

case 58:

dmd.drawString( 12,0, “58”, 2, GRAPHICS_NORMAL );

break;

case 59:

dmd.drawString( 12,0, “59”, 2, GRAPHICS_NORMAL );

break;

}

}void drawSec()

{

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

switch(second)

{

case 0:

dmd.drawString( 24,0, “00”, 2, GRAPHICS_NORMAL );

break;

case 1:

dmd.drawString( 24,0, “01”, 2, GRAPHICS_NORMAL );

break;

case 2:

dmd.drawString( 24,0, “02”, 2, GRAPHICS_NORMAL );

break;

case 3:

dmd.drawString( 24,0, “03”, 2, GRAPHICS_NORMAL );

break;

case 4:

dmd.drawString( 24,0, “04”, 2, GRAPHICS_NORMAL );

break;

case 5:

dmd.drawString( 24,0, “05”, 2, GRAPHICS_NORMAL );

break;

case 6:

dmd.drawString( 24,0, “06”, 2, GRAPHICS_NORMAL );

break;

case 7:

dmd.drawString( 24,0, “07”, 2, GRAPHICS_NORMAL );

break;

case 8:

dmd.drawString( 24,0, “08”, 2, GRAPHICS_NORMAL );

break;

case 9:

dmd.drawString( 24,0, “09”, 2, GRAPHICS_NORMAL );

break;

case 10:

dmd.drawString( 24,0, “10”, 2, GRAPHICS_NORMAL );

break;

case 11:

dmd.drawString( 24,0, “11”, 2, GRAPHICS_NORMAL );

break;

case 12:

dmd.drawString( 24,0, “12”, 2, GRAPHICS_NORMAL );

break;

case 13:

dmd.drawString( 24,0, “13”, 2, GRAPHICS_NORMAL );

break;

case 14:

dmd.drawString( 24,0, “14”, 2, GRAPHICS_NORMAL );

break;

case 15:

dmd.drawString( 24,0, “15”, 2, GRAPHICS_NORMAL );

break;

case 16:

dmd.drawString( 24,0, “16”, 2, GRAPHICS_NORMAL );

break;

case 17:

dmd.drawString( 24,0, “17”, 2, GRAPHICS_NORMAL );

break;

case 18:

dmd.drawString( 24,0, “18”, 2, GRAPHICS_NORMAL );

break;

case 19:

dmd.drawString( 24,0, “19”, 2, GRAPHICS_NORMAL );

break;

case 20:

dmd.drawString( 24,0, “20”, 2, GRAPHICS_NORMAL );

break;

case 21:

dmd.drawString( 24,0, “21”, 2, GRAPHICS_NORMAL );

break;

case 22:

dmd.drawString( 24,0, “22”, 2, GRAPHICS_NORMAL );

break;

case 23:

dmd.drawString( 24,0, “23”, 2, GRAPHICS_NORMAL );

break;

case 24:

dmd.drawString( 24,0, “24”, 2, GRAPHICS_NORMAL );

break;

case 25:

dmd.drawString( 24,0, “25”, 2, GRAPHICS_NORMAL );

break;

case 26:

dmd.drawString( 24,0, “26”, 2, GRAPHICS_NORMAL );

break;

case 27:

dmd.drawString( 24,0, “27”, 2, GRAPHICS_NORMAL );

break;

case 28:

dmd.drawString( 24,0, “28”, 2, GRAPHICS_NORMAL );

break;

case 29:

dmd.drawString( 24,0, “29”, 2, GRAPHICS_NORMAL );

break;

case 30:

dmd.drawString( 24,0, “30”, 2, GRAPHICS_NORMAL );

break;

case 31:

dmd.drawString( 24,0, “31”, 2, GRAPHICS_NORMAL );

break;

case 32:

dmd.drawString( 24,0, “32”, 2, GRAPHICS_NORMAL );

break;

case 33:

dmd.drawString( 24,0, “33”, 2, GRAPHICS_NORMAL );

break;

case 34:

dmd.drawString( 24,0, “34”, 2, GRAPHICS_NORMAL );

break;

case 35:

dmd.drawString( 24,0, “35”, 2, GRAPHICS_NORMAL );

break;

case 36:

dmd.drawString( 24,0, “36”, 2, GRAPHICS_NORMAL );

break;

case 37:

dmd.drawString( 24,0, “37”, 2, GRAPHICS_NORMAL );

break;

case 38:

dmd.drawString( 24,0, “38”, 2, GRAPHICS_NORMAL );

break;

case 39:

dmd.drawString( 24,0, “39”, 2, GRAPHICS_NORMAL );

break;

case 40:

dmd.drawString( 24,0, “40”, 2, GRAPHICS_NORMAL );

break;

case 41:

dmd.drawString( 24,0, “41”, 2, GRAPHICS_NORMAL );

break;

case 42:

dmd.drawString( 24,0, “42”, 2, GRAPHICS_NORMAL );

break;

case 43:

dmd.drawString( 24,0, “43”, 2, GRAPHICS_NORMAL );

break;

case 44:

dmd.drawString( 24,0, “44”, 2, GRAPHICS_NORMAL );

break;

case 45:

dmd.drawString( 24,0, “45”, 2, GRAPHICS_NORMAL );

break;

case 46:

dmd.drawString( 24,0, “46”, 2, GRAPHICS_NORMAL );

break;

case 47:

dmd.drawString( 24,0, “47”, 2, GRAPHICS_NORMAL );

break;

case 48:

dmd.drawString( 24,0, “48”, 2, GRAPHICS_NORMAL );

break;

case 49:

dmd.drawString( 24,0, “49”, 2, GRAPHICS_NORMAL );

break;

case 50:

dmd.drawString( 24,0, “50”, 2, GRAPHICS_NORMAL );

break;

case 51:

dmd.drawString( 24,0, “51”, 2, GRAPHICS_NORMAL );

break;

case 52:

dmd.drawString( 24,0, “52”, 2, GRAPHICS_NORMAL );

break;

case 53:

dmd.drawString( 24,0, “53”, 2, GRAPHICS_NORMAL );

break;

case 54:

dmd.drawString( 24,0, “54”, 2, GRAPHICS_NORMAL );

break;

case 55:

dmd.drawString( 24,0, “55”, 2, GRAPHICS_NORMAL );

break;

case 56:

dmd.drawString( 24,0, “56”, 2, GRAPHICS_NORMAL );

break;

case 57:

dmd.drawString( 24,0, “57”, 2, GRAPHICS_NORMAL );

break;

case 58:

dmd.drawString( 24,0, “58”, 2, GRAPHICS_NORMAL );

break;

case 59:

dmd.drawString( 24,0, “59”, 2, GRAPHICS_NORMAL );

break;

}

}void drawCol1()

{

dmd.drawString( 8,0, “:”, 1, GRAPHICS_NORMAL );

}void drawCol2()

{

dmd.drawString( 20,0, “:”, 1, GRAPHICS_NORMAL );

}void runClock()

{

// drawDay();

// drawDate();

drawHour();

drawCol1();

drawMinute();

drawCol2();

drawSec();

// CheckAlarm();}/*void AlarmSequence() {

drawDay();

drawDate();

drawHour();

drawCol();

drawMinute();

digitalWrite(Alarm, HIGH);

delay(1000);

dmd.clearScreen( true );

digitalWrite(Alarm, LOW);

delay(1000);

}

*/

/*void CheckAlarm() {

AlarmSet = digitalRead(AlarmSetPin);

Snooze = digitalRead(SnoozePin);

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);*/

/* Only Trigger Alarm If it is a day listed below. This can be changed by changing the numbers to any of the following:

1 = Sunday

2 = Monday

3 = Tuesday

4 = Wednesday

5 = Thursday

6 = Friday

7 = Saturday

*/

/* if(dayOfWeek == 2 || dayOfWeek == 3 || dayOfWeek == 4 || dayOfWeek == 5 ||dayOfWeek == 6) { //This is days ALLOWED to ring alarm

if(hour == 18 && minute == 05 ) { //Set Time Here (In 24 hour Time)

if(AlarmSet == LOW) { //If alarm pin is on

Snooze = digitalRead(SnoozePin);

while(Snooze == HIGH)

{

Snooze = digitalRead(SnoozePin);

AlarmSequence();

}

}

}

}

}

*/

void loop()

{

runClock();

}

第4步:功能

DMD

32 x 16个高亮度红色LED(总共512个LED),间距为10mm

支持5V操作

可以在12米远的地方看到

坚固的塑料框架

板载控制器IC

Arduino兼容库,图形功能

RTC

计算秒,分钟,小时和年份

Accura cy:0ºC至+40ºC时为+ 2ppm至-2ppm,-40ºC至+85ºC时为+ 3.5ppm至-3.5ppm

数字温度传感器,精度为±3ºC

两次日警报

可编程方波输出

寄存器老化调整400Khz I2C接口

低功耗

自动断电电池开关电路

CR2032备用电池,使用寿命为两到三年

步骤5:该项目的工作:简单时钟

第6步:该项目的工作:按设置进行计时

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分