Die Uhr, RTC DS1307 Dies ist das Uhrenmodul des Roboters:

Mit der oberen Stiftleiste wird das Modul mit der MCU verbunden, an die untere kann ein weiterer I2C Teilnehmen angeschlossen werden.
An der unteren Stiftleiste ist auch das 'SQUARE-WAVE OUT' (SO) Signal des DS1307 zugänglich, DS ist das Signal des optional einbaubarem Thermometers DS18B20.
Ein Sketch zum stellen der Uhrzeit:
/*Reads the value from a Real Time Clock (RTC) DS1307 and displays it in the serial monitor
*
*Created by D. Sjunnesson 1scale1.com d.sjunnesson (at) 1scale1.com
*
*Created with combined information from
*http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1180908809
*http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1191209057
*
*
*Big credit to mattt (please contact me for a more correct name...) from the Arduino forum
*which has written the main part of the library which I have modified
*
*/
#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h> // written by mattt on the Arduino forum and modified by D. Sjunnesson
void setup()
{
Serial.begin(9600);
RTC.stop();
RTC.set(DS1307_SEC,0); //set the seconds
RTC.set(DS1307_MIN,43); //set the minutes
RTC.set(DS1307_HR,0); //set the hours
RTC.set(DS1307_DOW,1); //set the day of the week
RTC.set(DS1307_DATE,1); //set the date
RTC.set(DS1307_MTH,7); //set the month
RTC.set(DS1307_YR,12); //set the year
RTC.start();
}
void loop()
{
Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
Serial.print(":");
Serial.print(RTC.get(DS1307_SEC,false));//read seconds
Serial.print(" "); // some space for a more happy life
Serial.print(RTC.get(DS1307_DATE,false));//read date
Serial.print("/");
Serial.print(RTC.get(DS1307_MTH,false));//read month
Serial.print("/");
Serial.print(RTC.get(DS1307_YR,false)); //read year
Serial.println();
Wire.beginTransmission(1);
Wire.send(DS1307_HR);
Wire.send(DS1307_MIN);
Wire.endTransmission();
}
Ein Sketch zur Ausgabe der Uhrzeit über das Terminal:
/*Reads the value from a Real Time Clock (RTC) DS1307 and displays it in the serial monitor
*
*Created by D. Sjunnesson 1scale1.com d.sjunnesson (at) 1scale1.com
*
*Created with combined information from
*http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1180908809
*http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1191209057
*
*
*Big credit to mattt (please contact me for a more correct name...) from the Arduino forum
*which has written the main part of the library which I have modified
*
*/
#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h> // written by mattt on the Arduino forum and modified by D. Sjunnesson
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
Serial.print(":");
Serial.print(RTC.get(DS1307_SEC,false));//read seconds
Serial.print(" "); // some space for a more happy life
Serial.print(RTC.get(DS1307_DATE,false));//read date
Serial.print("/");
Serial.print(RTC.get(DS1307_MTH,false));//read month
Serial.print("/");
Serial.print(RTC.get(DS1307_YR,false)); //read year
Serial.println();
Wire.beginTransmission(1);
Wire.send(DS1307_HR);
Wire.send(DS1307_MIN);
Wire.endTransmission();
}