Hello;
My name is Richard. I am new to this forum. I am working on a christmas project for my close family members. It is a Hexadecimal clock.
//intuitor.com/hex/hexclock.html
sadly i cant post links yet
I have the board built and the software working but for some reason it seems to be off by about 1 hex minute every 24 hour period.
Im hoping that some one can help me figure out what is going wrong here. Please note that i am not formally educated in either electronics or software. Although I have been dabbling in both of these fields for most of my life. Any insight you may have will be helpfull. If you would like me to post the schematic / board i will be happy to do so.
--Richard
/*Software for controlling a hexadecimal clock based around
3 motoroloa mc14495p
Richard de Leon 08-03-2010
*/
unsigned long WorkVar ;
unsigned long IncTime = 0;
unsigned int SecondCount = 0;
unsigned int MinuteACount = 0;
unsigned int MinuteBCount = 0;
unsigned int HourCount = 0;
int IncMinPin = 2;
int IncHourPin = 3; // assign the minute / hour set buttons to pins.
int Seconds1Pin = 18;
int Seconds2Pin = 19;
int Seconds4Pin = 4;
int Seconds8Pin = 5; // assign the binary representation of the seconds to their pins
int MinutesA1Pin = 6;
int MinutesA2Pin = 7;
int MinutesA4Pin = 8;
int MinutesA8Pin = 9;
int MinutesB1Pin = 10;
int MinutesB2Pin = 11;
int MinutesB4Pin = 12;
int MinutesB8Pin = 13;
int Hours1Pin = 14;
int Hours2Pin = 15;
int Hours4Pin = 16;
int Hours8Pin = 17;
void setup() {
pinMode(IncMinPin, INPUT);
pinMode(IncHourPin, INPUT);
pinMode(Seconds1Pin, OUTPUT);
pinMode(Seconds2Pin, OUTPUT);
pinMode(Seconds4Pin, OUTPUT);
pinMode(Seconds8Pin, OUTPUT);
pinMode(MinutesA1Pin, OUTPUT);
pinMode(MinutesA2Pin, OUTPUT);
pinMode(MinutesA4Pin, OUTPUT);
pinMode(MinutesA8Pin, OUTPUT);
pinMode(MinutesB1Pin, OUTPUT);
pinMode(MinutesB2Pin, OUTPUT);
pinMode(MinutesB4Pin, OUTPUT);
pinMode(MinutesB8Pin, OUTPUT);
pinMode(Hours1Pin, OUTPUT);
pinMode(Hours2Pin, OUTPUT);
pinMode(Hours4Pin, OUTPUT);
pinMode(Hours8Pin, OUTPUT);
attachInterrupt(0, IncMinutes, RISING);
attachInterrupt(1, IncHours, RISING);
}
void loop(){
//delay(1320);
// WorkVar = (millis - IncTime);
if (millis() - IncTime >= 1318 ){
SecondCount ++;
if (SecondCount >= 16){
SecondCount = 0;
MinuteACount++;
if (MinuteACount >= 16){
MinuteACount = 0;
MinuteBCount++ ;
if (MinuteBCount >= 16){
MinuteBCount = 0;
HourCount++;
if (HourCount >= 16){
HourCount = 0;
}
}
}
}
Update();
}
}
void Update(){
digitalWrite(Seconds1Pin, (bitRead(SecondCount, 0)));
digitalWrite(Seconds2Pin, (bitRead(SecondCount, 1)));
digitalWrite(Seconds4Pin, (bitRead(SecondCount, 2)));
digitalWrite(Seconds8Pin, (bitRead(SecondCount, 3)));
digitalWrite(MinutesA1Pin, (bitRead(MinuteACount, 0)));
digitalWrite(MinutesA2Pin, (bitRead(MinuteACount, 1)));
digitalWrite(MinutesA4Pin, (bitRead(MinuteACount, 2)));
digitalWrite(MinutesA8Pin, (bitRead(MinuteACount, 3)));
digitalWrite(MinutesB1Pin, (bitRead(MinuteBCount, 0)));
digitalWrite(MinutesB2Pin, (bitRead(MinuteBCount, 1)));
digitalWrite(MinutesB4Pin, (bitRead(MinuteBCount, 2)));
digitalWrite(MinutesB8Pin, (bitRead(MinuteBCount, 3)));
digitalWrite(Hours1Pin, (bitRead(HourCount, 0)));
digitalWrite(Hours2Pin, (bitRead(HourCount, 1)));
digitalWrite(Hours4Pin, (bitRead(HourCount, 2)));
digitalWrite(Hours8Pin, (bitRead(HourCount, 3)));
IncTime = millis();
}
void IncMinutes(){
MinuteACount++;
if (MinuteACount >= 16){
MinuteACount = 0;
MinuteBCount++;
if (MinuteBCount >15){
MinuteBCount = 0;
}
}
Update();
}
void IncHours(){
HourCount++;
if (HourCount > 15){
HourCount = 0;
}
Update();
}