Created
October 3, 2016 09:15
-
-
Save jochasinga/463282cd00e4fa4e447f5085ad93a8ef to your computer and use it in GitHub Desktop.
Get and print local time from an Arduino Yun.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Process.h> | |
Process date; // process used to get the date | |
int dates, month, years, hours, minutes, seconds; // for the results | |
int lastSecond = -1; // need an impossible value for comparison | |
void setup() { | |
Bridge.begin(); // initialize Bridge | |
Serial.begin(9600); // initialize serial | |
while(!Serial); // wait for Serial Monitor to open | |
Serial.println("Time Check"); // Title of sketch | |
} | |
void loop() { | |
date.begin("/bin/date"); | |
date.addParameter("+%d/%m/%Y %T"); | |
date.run(); | |
while (date.available()>0) { | |
String timeString = date.readString(); | |
Serial.println(timeString); | |
} | |
delay(5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment