Pages: [1]   Go Down
Author Topic: A clock synchronized by circadian rhythm  (Read 2572 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Circadian clock sets its time by observing dusk and dawn. Once it's set, it shouldn't be offset by bad weather. The clock is useful for controlling events in your garden without ever having to set time manually, via NTP or via GPS.

Code and description is available at http://www.fgh.si/2/.

Usage should be simple.

Code:
#include <Circadian.h>

// create a clock on analog pin 0 with dusk threshold 500
Circadian cclock(0, 500);

void setup()
{
}

void loop()
{
  // sample the sensor
  cclock.sample();

  // handle triggers, if any
  if(cclock.doTriggers())
  {
    if(cclock.triggerDawn(CCTIME(0,30,0)))
    {
      // do something after dawn
    }
    if(cclock.triggerDusk(CCTIME(0,-30,0)))
    {
      // do something before dusk
    }
    if(cclock.trigger(CCTIME(12,5,0)))
    {
      // do something at 12:05
    }
  }

  delay(1000);
}


Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13479
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I like the idea !



Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So do I need to start this sketch at a particular time starting off. I started it last night and it triggered dawn in the middle of the night and 12:30 in the morning. here is the what it spit out

Code:
CCircadian clock.
0:0; 6:0; 0; 426
0:1; 6:0; 0; 618
0:2; 6:0; 0; 620
0:3; 6:0; 0; 0
0:4; 6:0; 0; 369
0:5; 6:0; 0; 388
0:6; 6:0; 0; 233
0:7; 6:0; 0; 234
0:8; 6:0; 0; 234
0:9; 6:0; 0; 234
0:10; 6:0; 0; 234
0:11; 6:0; 0; 234
0:12; 6:0; 0; 235
0:13; 6:0; 0; 234
0:14; 6:0; 0; 234
0:15; 6:0; 0; 235
0:16; 6:0; 0; 0
0:17; 6:0; 0; 0
0:18; 6:0; 0; 0
bunch of the same here
6:23; 6:0; 0; 0
6:24; 6:0; 0; 0
6:25; 6:0; 0; 0
6:26; 6:0; 0; 0
6:27; 6:0; 0; 0
6:28; 6:0; 0; 0
6:29; 6:0; 0; 0
Trigger at dawn + 0:30.
6:30; 6:0; 0; 0
6:31; 6:0; 0; 0
6:32; 6:0; 0; 0
6:33; 6:0; 0; 0
6:34; 6:0; 0; 0
Sun Starts to come up
10:32; 6:0; 0; 0
10:33; 6:0; 0; 0
10:34; 6:0; 0; 0
10:35; 6:0; 0; 1
10:36; 6:0; 0; 2
10:37; 6:0; 0; 3
10:38; 6:0; 0; 4
10:39; 6:0; 0; 5
10:40; 6:0; 0; 6
10:41; 6:0; 0; 7
10:42; 6:0; 0; 9
10:43; 6:0; 0; 11
10:44; 6:0; 0; 12
10:45; 6:0; 0; 14
10:46; 6:0; 0; 15
10:47; 6:0; 0; 17
10:48; 6:0; 0; 18
10:49; 6:0; 0; 20
10:50; 6:0; 0; 21
10:51; 6:0; 0; 23
10:52; 6:0; 0; 25
10:53; 6:0; 0; 28
10:54; 6:0; 0; 30
10:55; 6:0; 0; 32
10:56; 6:0; 0; 34
10:57; 6:0; 0; 38
10:58; 6:0; 0; 42
10:59; 6:0; 0; 46
11:0; 6:0; 0; 50
11:1; 6:0; 0; 54
11:2; 6:0; 0; 58
11:3; 6:0; 0; 62
11:4; 6:0; 0; 66
11:5; 6:0; 0; 68
11:6; 6:0; 0; 66
11:7; 6:0; 0; 65
11:8; 6:0; 0; 65
11:9; 6:0; 0; 66
11:10; 6:0; 0; 66
11:11; 6:0; 0; 67
11:12; 6:0; 0; 69
11:13; 6:0; 0; 71
11:14; 6:0; 0; 73
11:15; 6:0; 0; 74
11:16; 6:0; 0; 75
11:17; 6:0; 0; 77
11:18; 6:0; 0; 79
11:19; 6:0; 0; 80
11:20; 6:0; 0; 83
11:21; 6:0; 0; 90
11:22; 6:0; 0; 94
11:23; 6:0; 0; 101
11:24; 6:0; 0; 108
11:25; 6:0; 0; 116
11:26; 6:0; 0; 121
11:27; 6:0; 0; 123
11:28; 6:0; 0; 121
11:29; 6:0; 0; 121
11:30; 6:0; 0; 122
11:31; 6:0; 0; 120
11:32; 6:0; 0; 120
11:33; 6:0; 0; 119
11:34; 6:0; 0; 119
11:35; 6:0; 0; 121
11:36; 6:0; 0; 123
11:37; 6:0; 0; 123
11:38; 6:0; 0; 122
11:39; 6:0; 0; 123
11:40; 6:0; 0; 126
11:41; 6:0; 0; 126
11:42; 6:0; 0; 132
11:43; 6:0; 0; 140
11:44; 6:0; 0; 149
11:45; 6:0; 0; 156
11:46; 6:0; 0; 160
11:47; 6:0; 0; 165
11:48; 6:0; 0; 168
11:49; 6:0; 0; 163
11:50; 6:0; 0; 170
11:51; 6:0; 0; 176
11:52; 6:0; 0; 179
11:53; 6:0; 0; 184
11:54; 6:0; 0; 188
11:55; 6:0; 0; 191
11:56; 6:0; 0; 192
11:57; 6:0; 0; 197
11:58; 6:0; 0; 201
11:59; 6:0; 0; 204
12:0; 6:0; 0; 205
12:1; 6:0; 0; 204
12:2; 6:0; 0; 205
12:3; 6:0; 0; 207
12:4; 6:0; 0; 211
Trigger at 12:5.
12:5; 6:0; 0; 216
12:6; 6:0; 0; 220
12:7; 6:0; 0; 222
12:8; 6:0; 0; 218
12:9; 6:0; 0; 216
12:10; 6:0; 0; 205
12:11; 6:0; 0; 216
12:12; 6:0; 0; 220
12:13; 6:0; 0; 231
12:14; 6:0; 0; 232
12:15; 6:0; 0; 236
12:16; 6:0; 0; 261
12:17; 6:0; 0; 264
12:18; 6:0; 0; 268
12:19; 6:0; 0; 267
12:20; 6:0; 0; 254
12:21; 6:0; 0; 252
12:22; 6:0; 0; 248
12:23; 6:0; 0; 245
12:24; 6:0; 0; 240
12:25; 6:0; 0; 252
12:26; 6:0; 0; 263
12:27; 6:0; 0; 281
12:28; 6:0; 0; 279
12:29; 6:0; 0; 280
12:30; 6:0; 0; 284
12:31; 6:0; 0; 291
12:32; 6:0; 0; 290
12:33; 6:0; 0; 294
12:34; 6:0; 0; 292
12:35; 6:0; 0; 281
12:36; 6:0; 0; 289
12:37; 6:0; 0; 282
12:38; 6:0; 0; 293
12:39; 6:0; 0; 278
12:40; 6:0; 0; 298
12:41; 6:0; 0; 279
12:42; 6:0; 0; 270
12:43; 6:0; 0; 266
12:44; 6:0; 0; 285
12:45; 6:0; 0; 294
12:46; 6:0; 0; 279
12:47; 6:0; 0; 268
12:48; 6:0; 0; 292
12:49; 6:0; 0; 302
12:50; 6:0; 0; 304
12:51; 6:0; 0; 302
12:52; 6:0; 0; 297
12:53; 6:0; 0; 267
12:54; 6:0; 0; 326
12:55; 6:0; 0; 357
12:56; 6:0; 0; 360
12:57; 6:0; 0; 385
12:58; 6:0; 0; 381
12:59; 6:0; 0; 378
13:0; 6:0; 0; 332
13:1; 6:0; 0; 363
13:2; 6:0; 0; 380
13:3; 6:0; 0; 395

Logged

Pages: [1]   Go Up
Jump to: