/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 src/propeller-clock.ino

  • Committer: edam
  • Date: 2012-01-14 17:31:00 UTC
  • Revision ID: edam@waxworlds.org-20120114173100-6gt6jte0j40cchj8
initialise from real-time clock; updated Makefile

Show diffs side-by-side

added added

removed removed

35
35
   13 is at the outside.
36
36
 
37
37
 * if a longer hand (and a larger clock face) is desired, pin 4 can be
38
 
   used to indirectly drive (via a MOSFET) multiple LEDs which turn on
39
 
   and off in unison in the centre of the clock.
 
38
   used to indirectly drive a transistor which in turn drives several
 
39
   LEDs that turn on anf off in unison in the centre of the clock.
40
40
 
41
41
 * a button should be attached to pin 3 that grounds it when pressed.
42
42
 
 
43
 * A DS1307 remote clock is connected via I2C on analog pins 4 and 5.
 
44
 
43
45
Implementation details:
44
46
 
45
 
 * for a schematic, see project/propeller-clock.sch.
 
47
 * for a schematic, see ../project/propeller-clock.sch.
46
48
 
47
49
 * the timing of the drawing of the clock face is recalculated with
48
50
   every rotation of the propeller.
67
69
    - pressing the button increments the field currently being set
68
70
    - pressing and holding the button for a second cycles through the
69
71
      fields that can be set
70
 
    - press and holding the button for 5 seconds to finish
 
72
    - pressing and holding the button for 5 seconds sets the time and
 
73
      exits "time set" mode
71
74
 
72
75
******************************************************************************/
73
76
 
74
77
 
75
78
#include <Bounce.h>
 
79
#include <DS1307.h>
 
80
#include <Wire.h>
76
81
 
77
82
//_____________________________________________________________________________
78
83
//                                                                         data
304
309
        // set up mode-switch button on pin 3
305
310
        pinMode( 3, INPUT );
306
311
 
 
312
        // get the time from the real-time clock
 
313
        int rtc_data[ 7 ];
 
314
        RTC.get( rtc_data, true );
 
315
        time_hours = rtc_data[ DS1307_HR ];
 
316
        time_minutes = rtc_data[ DS1307_MIN ];
 
317
        time_seconds = rtc_data[ DS1307_SEC ];
 
318
 
307
319
        // serial comms
308
320
        Serial.begin( 9600 );
309
321
}