Components and supplies
1
LCD Keypad Shield
1
9V 1A Switching Wall Power Supply
1
1x4 4 pin stackable header
1
Arduino UNO
1
DS3231M - ±5ppm, I2C Real-Time Clock
Tools and machines
1
Soldering iron (generic)
1
Solder Flux, Soldering
1
Solder Wire, Lead Free
Apps and platforms
1
Arduino IDE
Project description
Code
Multi Time Zone Clock
c_cpp
Clock with menu and output of date time of local time zone as well as 2 other time zones.
1#include <LiquidCrystal.h> 2#include "LCDKeypad.h" 3#include "Wire.h" 4 5//DS3231 6 address bus: 7#define DS3231_I2C_ADDRESS 0x68 8 9//Date: 10#define YEAR 0 11#define 12 MONTH 1 13#define DAYS 2 14#define WEEKDAY 3 15 16//weekday state: 17#define 18 SUN 0 19#define MON 1 20#define TUE 2 21#define WED 3 22#define THU 4 23#define 24 FRI 5 25#define SAT 6 26 27//Time: 28#define HOURS 0 29#define MINUTES 1 30#define 31 SECONDS 2 32 33//menu list: 34#define IDLEMENU 0 35#define SETDATE 1 36#define 37 SETTIME 2 38#define DONE 3 39 40#define hour1 41#define hour2 42 43// The 44 LCD screen 45LCDKeypad lcd; 46 47// The time model 48byte year = 0; 49byte 50 month = 1; 51byte days = 1; 52byte hours = 0; 53byte minutes = 0; 54byte seconds 55 = 0; 56byte weekday = 0; 57byte datesetting = 0; 58byte timesetting = 0; 59byte 60 menustate = 0; 61 62 63void setup() { 64 //initialize I2C and lcd: 65 lcd.begin(16,2); 66 67 68 Wire.begin(); 69 // Set the cursor at the begining of the first row 70 lcd.setCursor(0,0); 71 72 73 // Print a text in the first row 74 lcd.print("PRESS SELECT "); 75 lcd.setCursor(0,1); 76 77 lcd.print("TO SET DATETIME "); 78 //setDS3231time(30,06,17,3,11,5,16); 79 80 //delay(1000); 81 readDS3231time(&seconds, &minutes, &hours, &weekday, &days, 82 &month, &year); 83} 84 85void loop() { 86 // Increase the time model by one 87 second 88 incTime(); 89 //readDS3231time(&seconds, &minutes, &hours, &weekday, 90 &days, &month, &year); 91 // Print the time on the LCD 92 printTime(); 93 94 95 // Listen for buttons for 1 second 96 buttonListen(); 97} 98 99void buttonListen() 100 { 101 // Read the buttons five times in a second 102 for (int i = 0; i < 5; i++) 103 { 104 105 // Read the buttons value 106 int button = lcd.button(); 107 switch 108 (menustate){ 109 case SETDATE: 110 switch (button) { 111 // 112 Right button was pushed 113 case KEYPAD_RIGHT: 114 datesetting++; 115 116 break; 117 118 // Left button was pushed 119 case 120 KEYPAD_LEFT: 121 datesetting--; 122 if (datesetting == 123 -1) datesetting = 3; 124 break; 125 126 // Up button 127 was pushed 128 case KEYPAD_UP: 129 switch (datesetting) 130 { 131 case YEAR: 132 year++; 133 break; 134 135 case MONTH: 136 month++; 137 break; 138 139 case DAYS: 140 days++; 141 break; 142 143 case WEEKDAY: 144 weekday++; 145 } 146 147 break; 148 149 // Down button was pushed 150 case 151 KEYPAD_DOWN: 152 switch (datesetting) { 153 case YEAR: 154 155 year--; 156 if (year == -1) year = 99; 157 break; 158 159 case MONTH: 160 month--; 161 if (month 162 == 0) month = 12; 163 break; 164 case DAYS: 165 days--; 166 167 if (days == 0) days = 31; 168 break; 169 case 170 WEEKDAY: 171 weekday--; 172 if (weekday == 0) days 173 = 6; 174 } 175 } 176 break; 177 case SETTIME: 178 179 switch (button) { 180 // Right button was pushed 181 case 182 KEYPAD_RIGHT: 183 timesetting++; 184 break; 185 186 187 // Left button was pushed 188 case KEYPAD_LEFT: 189 timesetting--; 190 191 if (timesetting == -1) timesetting = 2; 192 break; 193 194 195 // Up button was pushed 196 case KEYPAD_UP: 197 198 switch (timesetting) { 199 case HOURS: 200 hours++; 201 202 break; 203 case MINUTES: 204 minutes++; 205 206 break; 207 case SECONDS: 208 seconds++; 209 210 } 211 break; 212 213 // Down 214 button was pushed 215 case KEYPAD_DOWN: 216 switch (timesetting) 217 { 218 case HOURS: 219 hours--; 220 if 221 (hours == -1) hours = 23; 222 break; 223 case MINUTES: 224 225 minutes--; 226 if (minutes == -1) minutes = 59; 227 228 break; 229 case SECONDS: 230 seconds--; 231 232 if (seconds == -1) seconds = 59; 233 } 234 } 235 236 break; 237 case DONE: 238 // DS3231 seconds, minutes, 239 hours, day, date, month, year 240 if (button== KEYPAD_SELECT) { 241 setDS3231time(seconds,minutes,hours,weekday,days,month,year); 242 243 } 244 } 245 if (button== KEYPAD_SELECT) { 246 menustate++; 247 248 } 249 datesetting %= 4; 250 timesetting %= 3; 251 menustate %=4; 252 253 printSetting(); 254 255 year %= 100; 256 month %= 13; 257 days %= 32; 258 259 hours %= 24; 260 minutes %= 60; 261 seconds %= 60; 262 weekday %=7; 263 264 printTime(); 265 266 // Wait one fifth of a second to complete 267 while(millis() 268 % 200 != 0); 269 } 270} 271 272// Print the current setting 273void printSetting() 274 { 275 switch (menustate){ 276 case SETDATE: 277 lcd.setCursor(0,0); 278 279 lcd.print("SETTING: "); 280 lcd.setCursor(9,0); 281 282 switch (datesetting) { 283 case YEAR: 284 lcd.print("YEAR 285 "); 286 break; 287 case MONTH: 288 lcd.print("MONTH 289 "); 290 break; 291 case DAYS: 292 lcd.print("Days 293 "); 294 break; 295 case WEEKDAY: 296 lcd.print("WeekDay"); 297 298 } 299 break; 300 case SETTIME: 301 lcd.setCursor(0,0); 302 303 lcd.print("SETTING: "); 304 lcd.setCursor(9,0); 305 306 switch (timesetting) { 307 case HOURS: 308 lcd.print("Hours 309 "); 310 break; 311 case MINUTES: 312 lcd.print("Minutes"); 313 314 break; 315 case SECONDS: 316 lcd.print("Seconds"); 317 318 } 319 break; 320 case IDLEMENU: 321 lcd.setCursor(0,0); 322 323 lcd.print("PRESS SELECT BTN"); 324 lcd.setCursor(0,1); 325 326 lcd.print("TO SET DATETIME "); 327 break; 328 case DONE: 329 330 lcd.clear(); 331 byte second, minute, hour, dayOfWeek, 332 dayOfMonth, month, year, hourP, hourM; 333 readDS3231time(&second, 334 &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); 335 336 // Calculate 337 Times zones based on main time zone 338 hourP = hour - 9; //change 339 time zone 1 calculation by changing the - 9 340 hourM = hour - 8; 341 // change time zone 2 calculation by changing the - 8 342 // Make 343 sure resulting number is not less than zero 344 if (hour < 8) //change 345 if time zone different 346 { hourP = hour + 15; //change if time 347 zone different 348 } 349 if (hour < 7) //change 350 if time zone different 351 { hourM = hour + 16; //change if time 352 zone different 353 } 354 355 // Print final result on 356 the screen 357 lcd.print("HAM "); 358 if(hour<10) lcd.print("0"); 359 360 lcd.print(hour); 361 lcd.print(":"); 362 if(minute<10) 363 lcd.print("0"); 364 lcd.print(minute); 365 lcd.print(" 366 "); 367 if(month<10) lcd.print("0"); 368 lcd.print(month); 369 370 lcd.print("/"); 371 if(dayOfMonth<10) lcd.print("0"); 372 373 lcd.print(dayOfMonth); 374 lcd.setCursor(0,1); 375 lcd.print("PT 376 "); // adjust the time zone 1 printed output here. Keep the space. 377 lcd.print(hourP); 378 379 lcd.print(":"); 380 if(minute<10) lcd.print("0"); 381 382 lcd.print(minute); 383 lcd.print(" "); 384 lcd.print("M 385 "); // adjust the time zone 2 printed output here. Keep the space. 386 lcd.print(hourM); 387 388 lcd.print(":"); 389 if(minute<10) lcd.print("0"); 390 391 lcd.print(minute); 392 lcd.print(" "); 393 394// Turn 395 off light after 10 pm, turn back on after 8 am - this is in a 24 hour clock 396 397 if (hour =22); // adjust the time in a 24 hour clock that you would 398 like the light to dim 399 lcd.noBacklight(); 400 if (hour =8); 401 // adjust the time in a 24 hour clock that you would like the light to light 402 up 403 lcd.backlight(); 404 405// Update every second (in miliseconds) 406 407 delay(1000); 408} 409} 410 411// Increase the time model by one second 412void 413 incTime() { 414 // Increase seconds 415 seconds++; 416 417 if (seconds == 60) 418 { 419 // Reset seconds 420 seconds = 0; 421 422 // Increase minutes 423 424 minutes++; 425 426 if (minutes == 60) { 427 // Reset minutes 428 minutes 429 = 0; 430 431 // Increase hours 432 hours++; 433 434 if (hours == 435 24) { 436 // Reset hours 437 hours = 0; 438 439 // Increase 440 days 441 days++; 442 weekday++; 443 } 444 } 445 } 446} 447 448// 449 Print the time on the LCD 450void printTime() { 451 char time[17]; 452 //check 453 which state right now: 454 switch(menustate){ 455 case SETDATE: 456 lcd.setCursor(0,1); 457 458 switch(weekday){ 459 case SUN: 460 sprintf(time, 461 "%02i/%02i/%02i SUN", year, month, days); 462 break; 463 case 464 MON: 465 sprintf(time, "%02i/%02i/%02i MON", year, month, days); 466 467 break; 468 case TUE: 469 sprintf(time, "%02i/%02i/%02i 470 TUE", year, month, days); 471 break; 472 case WED: 473 sprintf(time, 474 "%02i/%02i/%02i WED", year, month, days); 475 break; 476 case 477 THU: 478 sprintf(time, "%02i/%02i/%02i THU", year, month, days); 479 480 break; 481 case FRI: 482 sprintf(time, "%02i/%02i/%02i 483 FRI", year, month, days); 484 break; 485 case SAT: 486 sprintf(time, 487 "%02i/%02i/%02i SAT", year, month, days); 488 } 489 lcd.print(time); 490 491 break; 492 case SETTIME: 493 lcd.setCursor(0,1); 494 sprintf(time, 495 "%02i:%02i:%02i ", hours, minutes, seconds); 496 lcd.print(time); 497 498 } 499 // Set the cursor at the begining of the second row 500 501} 502// 503 Convert normal decimal numbers to binary coded decimal 504byte decToBcd(byte val) 505{ 506 507 return( (val/10*16) + (val%10) ); 508} 509// Convert binary coded decimal to normal 510 decimal numbers 511byte bcdToDec(byte val) 512{ 513 return( (val/16*10) + (val%16) 514 ); 515} 516 517void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, 518 byte dayOfMonth, byte month, byte year) 519{ 520 // sets time and date data to 521 DS3231 522 Wire.beginTransmission(DS3231_I2C_ADDRESS); 523 Wire.write(0); // set 524 next input to start at the seconds register 525 Wire.write(decToBcd(second)); // 526 set seconds 527 Wire.write(decToBcd(minute)); // set minutes 528 Wire.write(decToBcd(hour)); 529 // set hours 530 Wire.write(decToBcd(dayOfWeek)); // set day of week (0=Sunday, 531 6=Saturday) 532 Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31) 533 Wire.write(decToBcd(month)); 534 // set month 535 Wire.write(decToBcd(year)); // set year (0 to 99) 536 Wire.endTransmission(); 537} 538void 539 readDS3231time(byte *second,byte *minute,byte *hour,byte *dayOfWeek,byte *dayOfMonth,byte 540 *month,byte *year) 541{ 542 Wire.beginTransmission(DS3231_I2C_ADDRESS); 543 Wire.write(0); 544 // set DS3231 register pointer to 00h 545 Wire.endTransmission(); 546 Wire.requestFrom(DS3231_I2C_ADDRESS, 547 7); 548 // request seven bytes of data from DS3231 starting from register 00h 549 550 *second = bcdToDec(Wire.read() & 0x7f); 551 *minute = bcdToDec(Wire.read()); 552 553 *hour = bcdToDec(Wire.read() & 0x3f); 554 *dayOfWeek = bcdToDec(Wire.read()); 555 556 *dayOfMonth = bcdToDec(Wire.read()); 557 *month = bcdToDec(Wire.read()); 558 559 *year = bcdToDec(Wire.read()); 560 561}
Multi Time Zone Clock
c_cpp
Clock with menu and output of date time of local time zone as well as 2 other time zones.
1#include <LiquidCrystal.h> 2#include "LCDKeypad.h" 3#include "Wire.h" 4 5//DS3231 address bus: 6#define DS3231_I2C_ADDRESS 0x68 7 8//Date: 9#define YEAR 0 10#define MONTH 1 11#define DAYS 2 12#define WEEKDAY 3 13 14//weekday state: 15#define SUN 0 16#define MON 1 17#define TUE 2 18#define WED 3 19#define THU 4 20#define FRI 5 21#define SAT 6 22 23//Time: 24#define HOURS 0 25#define MINUTES 1 26#define SECONDS 2 27 28//menu list: 29#define IDLEMENU 0 30#define SETDATE 1 31#define SETTIME 2 32#define DONE 3 33 34#define hour1 35#define hour2 36 37// The LCD screen 38LCDKeypad lcd; 39 40// The time model 41byte year = 0; 42byte month = 1; 43byte days = 1; 44byte hours = 0; 45byte minutes = 0; 46byte seconds = 0; 47byte weekday = 0; 48byte datesetting = 0; 49byte timesetting = 0; 50byte menustate = 0; 51 52 53void setup() { 54 //initialize I2C and lcd: 55 lcd.begin(16,2); 56 57 Wire.begin(); 58 // Set the cursor at the begining of the first row 59 lcd.setCursor(0,0); 60 61 // Print a text in the first row 62 lcd.print("PRESS SELECT "); 63 lcd.setCursor(0,1); 64 lcd.print("TO SET DATETIME "); 65 //setDS3231time(30,06,17,3,11,5,16); 66 //delay(1000); 67 readDS3231time(&seconds, &minutes, &hours, &weekday, &days, &month, &year); 68} 69 70void loop() { 71 // Increase the time model by one second 72 incTime(); 73 //readDS3231time(&seconds, &minutes, &hours, &weekday, &days, &month, &year); 74 // Print the time on the LCD 75 printTime(); 76 77 // Listen for buttons for 1 second 78 buttonListen(); 79} 80 81void buttonListen() { 82 // Read the buttons five times in a second 83 for (int i = 0; i < 5; i++) { 84 85 // Read the buttons value 86 int button = lcd.button(); 87 switch (menustate){ 88 case SETDATE: 89 switch (button) { 90 // Right button was pushed 91 case KEYPAD_RIGHT: 92 datesetting++; 93 break; 94 95 // Left button was pushed 96 case KEYPAD_LEFT: 97 datesetting--; 98 if (datesetting == -1) datesetting = 3; 99 break; 100 101 // Up button was pushed 102 case KEYPAD_UP: 103 switch (datesetting) { 104 case YEAR: 105 year++; 106 break; 107 case MONTH: 108 month++; 109 break; 110 case DAYS: 111 days++; 112 break; 113 case WEEKDAY: 114 weekday++; 115 } 116 break; 117 118 // Down button was pushed 119 case KEYPAD_DOWN: 120 switch (datesetting) { 121 case YEAR: 122 year--; 123 if (year == -1) year = 99; 124 break; 125 case MONTH: 126 month--; 127 if (month == 0) month = 12; 128 break; 129 case DAYS: 130 days--; 131 if (days == 0) days = 31; 132 break; 133 case WEEKDAY: 134 weekday--; 135 if (weekday == 0) days = 6; 136 } 137 } 138 break; 139 case SETTIME: 140 switch (button) { 141 // Right button was pushed 142 case KEYPAD_RIGHT: 143 timesetting++; 144 break; 145 146 // Left button was pushed 147 case KEYPAD_LEFT: 148 timesetting--; 149 if (timesetting == -1) timesetting = 2; 150 break; 151 152 // Up button was pushed 153 case KEYPAD_UP: 154 switch (timesetting) { 155 case HOURS: 156 hours++; 157 break; 158 case MINUTES: 159 minutes++; 160 break; 161 case SECONDS: 162 seconds++; 163 } 164 break; 165 166 // Down button was pushed 167 case KEYPAD_DOWN: 168 switch (timesetting) { 169 case HOURS: 170 hours--; 171 if (hours == -1) hours = 23; 172 break; 173 case MINUTES: 174 minutes--; 175 if (minutes == -1) minutes = 59; 176 break; 177 case SECONDS: 178 seconds--; 179 if (seconds == -1) seconds = 59; 180 } 181 } 182 break; 183 case DONE: 184 // DS3231 seconds, minutes, hours, day, date, month, year 185 if (button== KEYPAD_SELECT) { 186 setDS3231time(seconds,minutes,hours,weekday,days,month,year); 187 } 188 } 189 if (button== KEYPAD_SELECT) { 190 menustate++; 191 } 192 datesetting %= 4; 193 timesetting %= 3; 194 menustate %=4; 195 printSetting(); 196 197 year %= 100; 198 month %= 13; 199 days %= 32; 200 hours %= 24; 201 minutes %= 60; 202 seconds %= 60; 203 weekday %=7; 204 printTime(); 205 206 // Wait one fifth of a second to complete 207 while(millis() % 200 != 0); 208 } 209} 210 211// Print the current setting 212void printSetting() { 213 switch (menustate){ 214 case SETDATE: 215 lcd.setCursor(0,0); 216 lcd.print("SETTING: "); 217 lcd.setCursor(9,0); 218 switch (datesetting) { 219 case YEAR: 220 lcd.print("YEAR "); 221 break; 222 case MONTH: 223 lcd.print("MONTH "); 224 break; 225 case DAYS: 226 lcd.print("Days "); 227 break; 228 case WEEKDAY: 229 lcd.print("WeekDay"); 230 } 231 break; 232 case SETTIME: 233 lcd.setCursor(0,0); 234 lcd.print("SETTING: "); 235 lcd.setCursor(9,0); 236 switch (timesetting) { 237 case HOURS: 238 lcd.print("Hours "); 239 break; 240 case MINUTES: 241 lcd.print("Minutes"); 242 break; 243 case SECONDS: 244 lcd.print("Seconds"); 245 } 246 break; 247 case IDLEMENU: 248 lcd.setCursor(0,0); 249 lcd.print("PRESS SELECT BTN"); 250 lcd.setCursor(0,1); 251 lcd.print("TO SET DATETIME "); 252 break; 253 case DONE: 254 lcd.clear(); 255 byte second, minute, hour, dayOfWeek, dayOfMonth, month, year, hourP, hourM; 256 readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); 257 258 // Calculate Times zones based on main time zone 259 hourP = hour - 9; //change time zone 1 calculation by changing the - 9 260 hourM = hour - 8; // change time zone 2 calculation by changing the - 8 261 // Make sure resulting number is not less than zero 262 if (hour < 8) //change if time zone different 263 { hourP = hour + 15; //change if time zone different 264 } 265 if (hour < 7) //change if time zone different 266 { hourM = hour + 16; //change if time zone different 267 } 268 269 // Print final result on the screen 270 lcd.print("HAM "); 271 if(hour<10) lcd.print("0"); 272 lcd.print(hour); 273 lcd.print(":"); 274 if(minute<10) lcd.print("0"); 275 lcd.print(minute); 276 lcd.print(" "); 277 if(month<10) lcd.print("0"); 278 lcd.print(month); 279 lcd.print("/"); 280 if(dayOfMonth<10) lcd.print("0"); 281 lcd.print(dayOfMonth); 282 lcd.setCursor(0,1); 283 lcd.print("PT "); // adjust the time zone 1 printed output here. Keep the space. 284 lcd.print(hourP); 285 lcd.print(":"); 286 if(minute<10) lcd.print("0"); 287 lcd.print(minute); 288 lcd.print(" "); 289 lcd.print("M "); // adjust the time zone 2 printed output here. Keep the space. 290 lcd.print(hourM); 291 lcd.print(":"); 292 if(minute<10) lcd.print("0"); 293 lcd.print(minute); 294 lcd.print(" "); 295 296// Turn off light after 10 pm, turn back on after 8 am - this is in a 24 hour clock 297 if (hour =22); // adjust the time in a 24 hour clock that you would like the light to dim 298 lcd.noBacklight(); 299 if (hour =8); // adjust the time in a 24 hour clock that you would like the light to light up 300 lcd.backlight(); 301 302// Update every second (in miliseconds) 303 delay(1000); 304} 305} 306 307// Increase the time model by one second 308void incTime() { 309 // Increase seconds 310 seconds++; 311 312 if (seconds == 60) { 313 // Reset seconds 314 seconds = 0; 315 316 // Increase minutes 317 minutes++; 318 319 if (minutes == 60) { 320 // Reset minutes 321 minutes = 0; 322 323 // Increase hours 324 hours++; 325 326 if (hours == 24) { 327 // Reset hours 328 hours = 0; 329 330 // Increase days 331 days++; 332 weekday++; 333 } 334 } 335 } 336} 337 338// Print the time on the LCD 339void printTime() { 340 char time[17]; 341 //check which state right now: 342 switch(menustate){ 343 case SETDATE: 344 lcd.setCursor(0,1); 345 switch(weekday){ 346 case SUN: 347 sprintf(time, "%02i/%02i/%02i SUN", year, month, days); 348 break; 349 case MON: 350 sprintf(time, "%02i/%02i/%02i MON", year, month, days); 351 break; 352 case TUE: 353 sprintf(time, "%02i/%02i/%02i TUE", year, month, days); 354 break; 355 case WED: 356 sprintf(time, "%02i/%02i/%02i WED", year, month, days); 357 break; 358 case THU: 359 sprintf(time, "%02i/%02i/%02i THU", year, month, days); 360 break; 361 case FRI: 362 sprintf(time, "%02i/%02i/%02i FRI", year, month, days); 363 break; 364 case SAT: 365 sprintf(time, "%02i/%02i/%02i SAT", year, month, days); 366 } 367 lcd.print(time); 368 break; 369 case SETTIME: 370 lcd.setCursor(0,1); 371 sprintf(time, "%02i:%02i:%02i ", hours, minutes, seconds); 372 lcd.print(time); 373 } 374 // Set the cursor at the begining of the second row 375 376} 377// Convert normal decimal numbers to binary coded decimal 378byte decToBcd(byte val) 379{ 380 return( (val/10*16) + (val%10) ); 381} 382// Convert binary coded decimal to normal decimal numbers 383byte bcdToDec(byte val) 384{ 385 return( (val/16*10) + (val%16) ); 386} 387 388void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year) 389{ 390 // sets time and date data to DS3231 391 Wire.beginTransmission(DS3231_I2C_ADDRESS); 392 Wire.write(0); // set next input to start at the seconds register 393 Wire.write(decToBcd(second)); // set seconds 394 Wire.write(decToBcd(minute)); // set minutes 395 Wire.write(decToBcd(hour)); // set hours 396 Wire.write(decToBcd(dayOfWeek)); // set day of week (0=Sunday, 6=Saturday) 397 Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31) 398 Wire.write(decToBcd(month)); // set month 399 Wire.write(decToBcd(year)); // set year (0 to 99) 400 Wire.endTransmission(); 401} 402void readDS3231time(byte *second,byte *minute,byte *hour,byte *dayOfWeek,byte *dayOfMonth,byte *month,byte *year) 403{ 404 Wire.beginTransmission(DS3231_I2C_ADDRESS); 405 Wire.write(0); // set DS3231 register pointer to 00h 406 Wire.endTransmission(); 407 Wire.requestFrom(DS3231_I2C_ADDRESS, 7); 408 // request seven bytes of data from DS3231 starting from register 00h 409 *second = bcdToDec(Wire.read() & 0x7f); 410 *minute = bcdToDec(Wire.read()); 411 *hour = bcdToDec(Wire.read() & 0x3f); 412 *dayOfWeek = bcdToDec(Wire.read()); 413 *dayOfMonth = bcdToDec(Wire.read()); 414 *month = bcdToDec(Wire.read()); 415 *year = bcdToDec(Wire.read()); 416 417}
Downloadable files
Boards together
This is the LCD Keypad shield mounted on the uno with the DS3231 mounted on the bottom.
Boards together

Comments
Only logged in users can leave comments