Hi folks
I'm new to this site and to Arduino so bear with me if I ask some stupid newbie questions.
The deal is I want to build a digital clock (hh:mm) using an Arduino Diecimila and 5mm LED's for the digits. I have a huge pile of LED's lying around so I think I'll use 4 LED's for each segment in each 7-segment digit, which amount to 112 LED's.
The problem is how to make the Arduino drive 28 segments and keep track of the time?
I've read a bit about Charlieplexing, and it should be possible to use this method, but it will get a bit complex. Is there an easier way?
And I've found some examples of Clock code but they all seem too complicated, I only need minutes and hours and not date or alarms. I would also like to be able to set the time on the clock after a reset without connecting to a computer, maybe just by using two buttons that increment the hours and minutes by 1 when pressed?
So please help me with my first Arduino project.
If you use the DateTime library in the playground, your code could be something like this
#include <DateTime.h>
int minutesSwitch = 2;
int hoursSwitch = 3;
void setup(){
pinMode(minutesSwitch, INPUT);
pinMode(hoursSwitch, INPUT);
DateTime.sync(0); // clock will start at midnight
}
void loop(){
DateTime.available(); //refresh the Date and time properties
if(digitalRead(minutesSwitch)) // note that these switches may need to have debounce code added !
DateTime.sync(DateTime.now() + 60); // add 60 seconds to time if switch is pressed
if(digitalRead(hoursSwitch))
DateTime.sync(DateTime.now() + 60 * 60); // add an hour to the time if the hour switch is pressed
displayMinutes(DateTime.Minute);
displayHours(DateTime.Hour);
}
void displayMinutes( byte minutes){
// your code to display minutes here
}
void displayHours(byte hours){
// your code to display hours here
}
It will need work on the display and handling the switch input, but the library will handle the time functions
Cool. But I think I have to figure out exactly how the DateTime library works before i fully understand your piece of code. I presume I need more code to get a working clock than what you wrote.