element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Enchanted Objects
  • Challenges & Projects
  • Design Challenges
  • Enchanted Objects
  • More
  • Cancel
Enchanted Objects
Blog Enchanted Objects - Enchanted Clock (#3)
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: dwinhold
  • Date Created: 4 Apr 2015 11:11 PM Date Created
  • Views 676 views
  • Likes 6 likes
  • Comments 4 comments
  • enchanted_objects
  • enchanted_clock
Related
Recommended

Enchanted Objects - Enchanted Clock (#3)

dwinhold
dwinhold
4 Apr 2015

Hello everyone,

 

So I have been programming the Arduino for enchanted clock I'm building (Work in progress). I am still having issues with the SAMA5D4 Xplained, I may have to change to an RPi if time starts to get tight. I really don't want to do this as our sponsors have been very generous and I don't want to let them down.

 

So to update where I am at. I have decided that for the clock to stay in time due to the inconsistency in a wood clock, I have made a binary clock. This clock will be integrated with my wood clock and through servos it will re-set it to the correct time. Below is a picture of the Binary Clock on the breadboard working. I will make a PCB board cape for final product. The time on the Binary Clock will be seen as well as the wood clock time.

 

image

 

 

Schematic:

image

Clock Code:

 

#include <Wire.h>
#include <RTClib.h>
#include <TimerOne.h>

byte numPins = 5;
byte ledPins[] = {2, 5, 8, 10, 12};

byte hourLeds[][2] = {{1, 3}, {3, 1}, {0, 3}, {3, 0}};
byte minLeds[][2] = {{4, 2}, {3, 4}, {2, 3}, {1, 2}, {0, 1}, {2, 0}};
byte secLeds[][2] = {{2, 4}, {4, 3}, {3, 2}, {2, 1}, {1, 0}, {0, 2}};

RTC_DS1307 RTC;

int hour, min, sec;

void setup()
{
  Wire.begin();
  if (! RTC.isrunning())
  {
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  Timer1.initialize(20000); // uS
  Timer1.attachInterrupt( refresh );
}

void loop()
{
  static long lastTick;
  long thisTick = millis();
  if (thisTick > lastTick + 500l) // every 0.5 seconds
  {
    DateTime now = RTC.now();
    hour = now.hour();
    min = now.minute();
    sec = now.second();
    lastTick = thisTick;
  }
  refresh();
}

void refresh()
{
  int s = sec;
  int m = min;
  int h = hour;
  for (int bit = 0; bit < 6; bit++)
  {
    if (s & 1)
    {
      setLed(secLeds[bit]);
     // delay(10);
    }
    s = s >> 1;
    if (m & 1)
    {
      setLed(minLeds[bit]);
    }
    m = m >> 1;
    if (h & 1 && bit < 4)
    {
      setLed(hourLeds[bit]);
    }
    h = h >> 1;
   }
   allOff(); // so last led not brighter
}

void setLed(byte pins[])
{
  byte plusPin = ledPins[pins[0]];
  byte minusPin = ledPins[pins[1]];
  allOff();
  pinMode(plusPin, OUTPUT);
  digitalWrite(plusPin, HIGH);
  pinMode(minusPin, OUTPUT);
  digitalWrite(plusPin, LOW);
}

void allOff()
{ 
  for (byte pin = 0; pin < numPins; pin++)
  {
    pinMode(ledPins[pin], INPUT);
  }
}

 

Servo controller and timing sensor to be programmed into the script, this is for the clock only (so far).

 

My big focus is on the wooden clock, this is a huge part in the whole project. I will update mid week with photos of the progress.

 

Dale & Chrystal Winhold

  • Sign in to reply

Top Comments

  • clem57
    clem57 over 10 years ago +2
    Good job. Like the idea of a binary clock.
  • Workshopshed
    Workshopshed over 10 years ago +2
    It took me a while to work out the LED wiring but I got it eventually, very cunning.
  • mcb1
    mcb1 over 10 years ago +2
    How long did it take you to work out that wiring. I had a headache just trying to follow it ... full marks. Mark
Parents
  • clem57
    clem57 over 10 years ago

    Good job. Like the idea of a binary clock.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • clem57
    clem57 over 10 years ago

    Good job. Like the idea of a binary clock.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube