garthoff / ds1337rtc Goto Github PK
View Code? Open in Web Editor NEWThis project forked from etrombly/ds1337rtc
arduino library for the DS1337 RTC
This project forked from etrombly/ds1337rtc
arduino library for the DS1337 RTC
Here is some example code for this library, I will expand the README more as I get an opportunity. #include <DS1337RTC.h> #include <Time.h> #include <Wire.h> #define alarmPin 12 char *monthName[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; void setup(){ pinMode(alarmPin, INPUT); digitalWrite(alarmPin,HIGH); Serial.begin(9600); tmElements_t tmSet; tmSet.Year = 2011 - 1970; tmSet.Month = 7; tmSet.Day = 3; tmSet.Hour = 20; tmSet.Minute = 13; tmSet.Second = 0; RTC.set(makeTime(tmSet), CLOCK_ADDRESS); // set the clock tmSet.Second = 4; RTC.set(makeTime(tmSet), ALARM1_ADDRESS); // set the alarm for 4 seconds later RTC.enableAlarm(ALARM1_ADDRESS); RTC.freqSelect(1); // set the squarewave freq on alarm pin b to 4.096kHz } void loop(){ time_t alarm = RTC.get(ALARM1_ADDRESS); // get the time the alarm is set for tmElements_t alarmSet; breakTime(alarm, alarmSet); //print the time using Time.h Serial.print(day()); Serial.print(" "); Serial.print(monthName[month() - 1]); Serial.print(" "); Serial.print(year()); Serial.print(" "); Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.print("\t"); // print the alarm time Serial.print("ALARM1: "); Serial.print((int)alarmSet.Day); Serial.print(" "); Serial.print((int)alarmSet.Hour); printDigits(alarmSet.Minute); printDigits(alarmSet.Second); Serial.print("\t"); if(digitalRead(alarmPin) == HIGH){ //pin is set low when alarm is triggered Serial.println("ALARM off"); }else{ Serial.println("ALARM on"); RTC.resetAlarms(); } delay(1000); } void printDigits(int digits){ // utility function for digital clock display: prints preceding colon and leading 0 Serial.print(":"); if(digits < 10) Serial.print('0'); Serial.print(digits); }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.