/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to test/rtc-test/rtc-ds1307.ino

  • Committer: Tim Marston
  • Date: 2012-05-18 18:29:50 UTC
  • Revision ID: tim@ed.am-20120518182950-t85bn9a21n72uzm8
text messages are now individually enabled and draw()n automatically

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <DS1307.h>
 
2
#include <Wire.h>
 
3
 
 
4
void setup()
 
5
{
 
6
#if 0
 
7
        RTC.stop();
 
8
        RTC.set( DS1307_YR, 12 );
 
9
        RTC.set( DS1307_MTH, 2 );
 
10
        RTC.set( DS1307_DAY, 25 );
 
11
        RTC.set( DS1307_HR, 14 );
 
12
        RTC.set( DS1307_MIN, 25 );
 
13
        RTC.set( DS1307_SEC, 0 );
 
14
//      RTC.set( DS1307_DOW, 4 );
 
15
        RTC.start();
 
16
#endif
 
17
 
 
18
        Serial.begin( 9600 );
 
19
 
 
20
        pinMode( 13, OUTPUT );
 
21
}
 
22
 
 
23
void loop()
 
24
{
 
25
        int rtc[ 7 ];
 
26
        RTC.get( rtc, true );
 
27
 
 
28
        Serial.print( rtc[ DS1307_YR ] );
 
29
        Serial.print( "-" );
 
30
        if( rtc[ DS1307_MTH ] < 10 ) Serial.print( "0" );
 
31
        Serial.print( rtc[ DS1307_MTH ] );
 
32
        Serial.print( "-" );
 
33
        if( rtc[ DS1307_DAY ] < 10 ) Serial.print( "0" );
 
34
        Serial.print( rtc[ DS1307_DAY ] );
 
35
        Serial.print( " " );
 
36
        if( rtc[ DS1307_HR ] < 10 ) Serial.print( "0" );
 
37
        Serial.print( rtc[ DS1307_HR ] );
 
38
        Serial.print( ":" );
 
39
        if( rtc[ DS1307_MIN ] < 10 ) Serial.print( "0" );
 
40
        Serial.print( rtc[ DS1307_MIN ] );
 
41
        Serial.print( ":" );
 
42
        if( rtc[ DS1307_SEC ] < 10 ) Serial.print( "0" );
 
43
        Serial.println( rtc[ DS1307_SEC ] );
 
44
 
 
45
    digitalWrite( 13, HIGH );
 
46
    delay( 100 );
 
47
    digitalWrite( 13, LOW );
 
48
    delay( 100 );
 
49
    digitalWrite( 13, HIGH );
 
50
    delay( 100 );
 
51
    digitalWrite( 13, LOW );
 
52
    delay( 700 );
 
53
}