first commit

This commit is contained in:
Jérôme Delacotte
2025-03-06 11:15:32 +01:00
commit 7b30d6e298
5276 changed files with 2108927 additions and 0 deletions

108
ATMEGA_TIMER_1/ATMEGA_TIMER_1.ino Executable file
View File

@@ -0,0 +1,108 @@
/*
DS1302 RTC module test by Tuxun
-CE/RST RTC pin D3(3)
-IO/DAT RTC pin D4(4)
-CLK RTC pin D5(5)
Under PUBLIC DOMAIN!
*/
//RTC part
//time from http://www.pjrc.com/teensy/arduino_libraries/Time.zip
#include <Time.h>
//DS1302 from http://playground.arduino.cc/uploads/Main/DS1302RTC.zip
#include <DS1302RTC.h>
// Set RTC pins: CE, IO,CLK
DS1302RTC RTC(3, 4, 5);
// Optional connection for RTC module: -1 to disable
#define DS1302_GND_PIN -1
#define DS1302_VCC_PIN -1
void setup()
{
//initial welcome :)
Serial.begin(9600);
Serial.println("DS1302 TEST PROGRAM");
Serial.println();
// Activate RTC module
digitalWrite(DS1302_GND_PIN, LOW);
pinMode(DS1302_GND_PIN, OUTPUT);
digitalWrite(DS1302_VCC_PIN, HIGH);
pinMode(DS1302_VCC_PIN, OUTPUT);
Serial.println("RTC module activated");
Serial.println();
delay(500);
//check that it is activated
if (RTC.haltRTC()) {
Serial.println("The DS1302 is stopped. Please run the SetTime");
Serial.println("example to initialize the time and begin running.");
Serial.println();
}
if (!RTC.writeEN()) {
Serial.println("The DS1302 is write protected. This normal.");
Serial.println();
}
delay(5000);
}
void loop()
{
Serial.println("\n");
//DS1302 timestamp structure
tmElements_t tm;
//Serial.print("UNIX Time: ");
//Serial.print(RTC.get());
if (! RTC.read(tm)) {
Serial.print(" Time = ");
print2digits(tm.Hour);
Serial.write(':');
print2digits(tm.Minute);
Serial.write(':');
print2digits(tm.Second);
Serial.print(", Date (D/M/Y) = ");
Serial.print(tm.Day);
Serial.write('/');
Serial.print(tm.Month);
Serial.write('/');
Serial.print(tmYearToCalendar(tm.Year));
Serial.print(", DoW = ");
Serial.print(tm.Wday);
Serial.println();
} else {
Serial.println("DS1302 read error! Please check the circuitry.");
Serial.println();
delay(9000);
}
// Wait one second before repeating :)
delay (1000);
}
void print2digits(int number) {
if (number >= 0 && number < 10)
Serial.write('0');
Serial.print(number);
}