CurieTime Read Test with Arduino 101
This example demonstrate how to use the CurieTime library methods.
Hardware Required
- Arduino 101 Board
Code
1/*2
3 * Copyright (c) 2016 Intel Corporation. All rights reserved.4
5 * See the bottom of this file for the license terms.6
7 */8
9#include <CurieTime.h>10
11void setup() {12
13 Serial.begin(9600); // initialize Serial communication14
15 while (!Serial); // wait for serial port to connect.16
17 Serial.println("CurieTime Read Test");18
19 Serial.println("-------------------");20}21
22void loop() {23
24 Serial.print("Ok, Time = ");25
26 print2digits(hour());27
28 Serial.write(':');29
30 print2digits(minute());31
32 Serial.write(':');33
34 print2digits(second());35
36 Serial.print(", Date (D/M/Y) = ");37
38 Serial.print(day());39
40 Serial.write('/');41
42 Serial.print(month());43
44 Serial.write('/');45
46 Serial.print(year());47
48 Serial.println();49
50 delay(1000);51}52
53void print2digits(int number) {54
55 if (number >= 0 && number < 10) {56
57 Serial.write('0');58
59 }60
61 Serial.print(number);62}63
64/*65
66 * Copyright (c) 2016 Intel Corporation. All rights reserved.67
68 *69
70 * This library is free software; you can redistribute it and/or71
72 * modify it under the terms of the GNU Lesser General Public73
74 * License as published by the Free Software Foundation; either75
76 * version 2.1 of the License, or (at your option) any later version.77
78 *79
80 * This library is distributed in the hope that it will be useful,81
82 * but WITHOUT ANY WARRANTY; without even the implied warranty of83
84 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU85
86 * Lesser General Public License for more details.87
88 *89
90 * You should have received a copy of the GNU Lesser General Public91
92 * License along with this library; if not, write to the Free Software93
94 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA95
96 */
Suggest changes
The content on docs.arduino.cc is facilitated through a public GitHub repository. If you see anything wrong, you can edit this page here.
License
The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.