Skip to content

Instantly share code, notes, and snippets.

@jochasinga
Created October 3, 2016 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jochasinga/463282cd00e4fa4e447f5085ad93a8ef to your computer and use it in GitHub Desktop.
Save jochasinga/463282cd00e4fa4e447f5085ad93a8ef to your computer and use it in GitHub Desktop.
Get and print local time from an Arduino Yun.
#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