binary watch

binary watch

thingiverse

arduinopart: /* TimeSerial.pde example code illustrating Time library set through serial port messages. Messages consist of the letter T followed by ten digit time (as seconds since Jan 1 1970) you can send the text on the next line using Serial Monitor to set the clock to noon Jan 1 2013 T1357041600 A Processing example sketch to automatically send the messages is inclided in the download On Linux, you can use "date +T%s > /dev/ttyACM0" (UTC time zone) */ include define TIME_HEADER "T" // Header tag for serial time sync message define TIME_REQUEST 7 // ASCII bell character requests a time sync message int mini[6] = {3,5,7,9,11,13}; int hou[5] = {4,6,8,10,12}; void setup() { Serial.begin(9600); while (!Serial) ; // Needed for Leonardo only setSyncProvider( requestSync); //set function to call when sync required Serial.println("Waiting for sync message"); for(int i = 0; i < 6; i++){ pinMode(mini[i], OUTPUT); } for(int i = 0; i < 5; i++){ pinMode(hou[i], OUTPUT); } } void loop(){ if (Serial.available()) { processSyncMessage(); } if (timeStatus()!= timeNotSet) { digitalClockDisplay(); } delay(1000); } void digitalClockDisplay(){ // digital clock display of the time Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.print(" "); Serial.print(day()); Serial.print(" "); Serial.print(month()); Serial.print(" "); Serial.print(year()); Serial.println(); if(minute() % 2 > 0){ // statement digitalWrite(mini[0], HIGH); } else { // statement digitalWrite(mini[0], LOW); } if(minute() % 4 > 1){ // statement digitalWrite(mini[1], HIGH); } else { // statement digitalWrite(mini[1], LOW); } if(minute() % 8 > 3){ // statement digitalWrite(mini[2], HIGH); } else { // statement digitalWrite(mini[2], LOW); } if(minute() % 16 > 7){ // statement digitalWrite(mini[3], HIGH); } else { // statement digitalWrite(mini[3], LOW); } if(minute() % 32 > 15){ // statement digitalWrite(mini[4], HIGH); } else { // statement digitalWrite(mini[4], LOW); } if(minute() % 64 > 31){ // statement digitalWrite(mini[5], HIGH); } else { // statement digitalWrite(mini[5], LOW); } if(hour() % 2 > 0){ // statement digitalWrite(hou[0], HIGH); } else { // statement digitalWrite(hou[0], LOW); } if(hour() % 4 > 1){ // statement digitalWrite(hou[1], HIGH); } else { // statement digitalWrite(hou[1], LOW); } if(hour() % 8 > 3){ // statement digitalWrite(hou[2], HIGH); } else { // statement digitalWrite(hou[2], LOW); } if(hour() % 16 > 7){ // statement digitalWrite(hou[3], HIGH); } else { // statement digitalWrite(hou[3], LOW); } if(hour() % 32 > 15){ // statement digitalWrite(hou[4], HIGH); } else { // statement digitalWrite(hou[4], LOW); } } void printDigits(int digits){ // utility function for digital clock display: prints preceding colon and leading 0 Serial.print(":"); if(digits < 10) Serial.print('0'); Serial.print(digits); } void processSyncMessage() { unsigned long pctime; const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 if(Serial.find(TIME_HEADER)) { pctime = Serial.parseInt(); if( pctime >= DEFAULT_TIME) { // check the integer is a valid time (greater than Jan 1 2013) setTime(pctime); // Sync Arduino clock to the time received on the serial port } } } time_t requestSync() { Serial.write(TIME_REQUEST); return 0; // the time will be sent later in response to serial mesg } processing part: /** SyncArduinoClock. portIndex must be set to the port connected to the Arduino The current time is sent in response to request message from Arduino or by clicking the display window The time message is 11 ASCII text characters; a header (the letter 'T') followed by the ten digit system time (unix time) */ import processing.serial.*; import java.util.Date; import java.util.Calendar; import java.util.GregorianCalendar; public static final short portIndex = 0; // select the com port, 0 is the first port public static final String TIME_HEADER = "T"; //header for arduino serial time message public static final char TIME_REQUEST = 7; // ASCII bell character public static final char LF = 10; // ASCII linefeed public static final char CR = 13; // ASCII linefeed Serial myPort; // Create object from Serial class void setup() { size(200, 200); println(Serial.list()); println(" Connecting to -> " + Serial.list()[portIndex]); myPort = new Serial(this,Serial.list()[portIndex], 9600); println(getTimeNow()); } void draw() { textSize(20); textAlign(CENTER); fill(0); text("Click to send\nTime Sync", 0, 75, 200, 175); if ( myPort.available() > 0) { // If data is available, char val = char(myPort.read()); // read it and store it in val if(val == TIME_REQUEST){ long t = getTimeNow(); sendTimeMessage(TIME_HEADER, t); } else { if(val == LF) ; //igonore else if(val == CR) println(); else print(val); // echo everying but time request } } } void mousePressed() { sendTimeMessage( TIME_HEADER, getTimeNow()); } void sendTimeMessage(String header, long time) { String timeStr = String.valueOf(time); myPort.write(header); // send header and time to arduino myPort.write(timeStr); myPort.write('\n'); } long getTimeNow(){ // java time is in ms, we want secs Date d = new Date(); Calendar cal = new GregorianCalendar(); long current = d.getTime()/1000; long timezone = cal.get(cal.ZONE_OFFSET)/1000; long daylight = cal.get(cal.DST_OFFSET)/1000; return current + timezone + daylight; }

Download Model from thingiverse

With this file you will be able to print binary watch with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on binary watch.