/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <DS1307.h>
#include <Wire.h>

void setup()
{
#if 0
	RTC.stop();
	RTC.set( DS1307_YR, 12 );
	RTC.set( DS1307_MTH, 2 );
	RTC.set( DS1307_DAY, 25 );
	RTC.set( DS1307_HR, 14 );
	RTC.set( DS1307_MIN, 25 );
	RTC.set( DS1307_SEC, 0 );
//	RTC.set( DS1307_DOW, 4 );
	RTC.start();
#endif

	Serial.begin( 9600 );

	pinMode( 13, OUTPUT );
}

void loop()
{
	int rtc[ 7 ];
	RTC.get( rtc, true );

	Serial.print( rtc[ DS1307_YR ] );
	Serial.print( "-" );
	if( rtc[ DS1307_MTH ] < 10 ) Serial.print( "0" );
	Serial.print( rtc[ DS1307_MTH ] );
	Serial.print( "-" );
	if( rtc[ DS1307_DAY ] < 10 ) Serial.print( "0" );
	Serial.print( rtc[ DS1307_DAY ] );
	Serial.print( " " );
	if( rtc[ DS1307_HR ] < 10 ) Serial.print( "0" );
	Serial.print( rtc[ DS1307_HR ] );
	Serial.print( ":" );
	if( rtc[ DS1307_MIN ] < 10 ) Serial.print( "0" );
	Serial.print( rtc[ DS1307_MIN ] );
	Serial.print( ":" );
	if( rtc[ DS1307_SEC ] < 10 ) Serial.print( "0" );
	Serial.println( rtc[ DS1307_SEC ] );

    digitalWrite( 13, HIGH );
    delay( 100 );
    digitalWrite( 13, LOW );
    delay( 100 );
    digitalWrite( 13, HIGH );
    delay( 100 );
    digitalWrite( 13, LOW );
    delay( 700 );
}