As the title states, I'm trying to combine the large numbers font made by Hifiduino (H I F I D U I N O C O D E | Arduino code for HIFIDUINO) and the crossroads clock that gets time set by buttons and does not rely on a RTC module. I am a complete noob when it comes to this, but I have read as much as I can figure out and have hit a wall. Anyone that could figure out what I'm doing wrong would have my gratitude.
[code]
/*
A set of custom made large numbers for a 16x2 LCD using the
LiquidCrystal librabry. Works with displays compatible with the
Hitachi HD44780 driver.
The Cuicuit:
LCD RS pin to D12
LCD Enable pin to D10
LCD D4 pin to D5
LCD D5 pin to D4
LCD D6 pin to D3
LCD D7 pin to D2
LCD Vee tied to a pot to control brightness
LCD Vss and R/W tied to ground
LCD Vcc to +5V
Made by Michael Pilcher
2/9/2010
*/
// include the library
#include <LiquidCrystal.h>
#include <Time.h>
#include <TimeLib.h>
// initialize the interface pins
LiquidCrystal lcd(12, 10, 5, 4, 3, 2);
const int backlight = 13;
const int buttonHr = 7; //digital pin used as hour adjustment input
const int buttonMin = 8; //digital pin used as min adjustment input
int secs = 0;
int secs2 = 0;
int mins = -1;
int hrs = 0;
int milliDivSecs = 1000;
int milliDivMins = 60000;
int milliDivHrs = 360000;
unsigned long prevmillis = 0;
int interval = 1000;
int x = 0;
pinMode(backlight, OUTPUT);
pinMode(buttonHr, INPUT);
pinMode(buttonMin, INPUT);
digitalWrite(backlight, HIGH);
lcd.begin(16, 2); //set number of cols and rows
//print out LCD clock duisplay
lcd.setCursor(5, 0);
lcd.print("12:00:00 AM");
Serial.begin(9600);
}
// the 8 arrays that form each segment of the custom numbers
byte LT[8] =
{
B00111,
B01111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
};
byte UB[8] =
{
B11111,
B11111,
B11111,
B00000,
B00000,
B00000,
B00000,
B00000
};
byte RT[8] =
{
B11100,
B11110,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
};
byte LL[8] =
{
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B01111,
B00111
};
byte LB[8] =
{
B00000,
B00000,
B00000,
B00000,
B00000,
B11111,
B11111,
B11111
};
byte LR[8] =
{
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11110,
B11100
};
byte UMB[8] =
{
B11111,
B11111,
B11111,
B00000,
B00000,
B00000,
B11111,
B11111
};
byte LMB[8] =
{
B11111,
B00000,
B00000,
B00000,
B00000,
B11111,
B11111,
B11111
};
void setup()
{
// assignes each segment a write number
lcd.createChar(8, LT);
lcd.createChar(1, UB);
lcd.createChar(2, RT);
lcd.createChar(3, LL);
lcd.createChar(4, LB);
lcd.createChar(5, LR);
lcd.createChar(6, UMB);
lcd.createChar(7, LMB);
// sets the LCD's rows and colums:
lcd.begin(0, 2);
}
void custom0O()
{ // uses segments to build the number 0
lcd.setCursor(x, 0);
lcd.write(8);
lcd.write(1);
lcd.write(2);
lcd.setCursor(x, 1);
lcd.write(3);
lcd.write(4);
lcd.write(5);
}
void custom1()
{
lcd.setCursor(x, 0);
lcd.write(1);
lcd.write(2);
lcd.setCursor(x + 1, 1);
lcd.write(255);
}
void custom2()
{
lcd.setCursor(x, 0);
lcd.write(6);
lcd.write(6);
lcd.write(2);
lcd.setCursor(x, 1);
lcd.write(3);
lcd.write(7);
lcd.write(7);
}
void custom3()
{
lcd.setCursor(x, 0);
lcd.write(6);
lcd.write(6);
lcd.write(2);
lcd.setCursor(x, 1);
lcd.write(7);
lcd.write(7);
lcd.write(5);
}
void custom4()
{
lcd.setCursor(x, 0);
lcd.write(3);
lcd.write(4);
lcd.write(2);
lcd.setCursor(x + 2, 1);
lcd.write(255);
}
void custom5()
{
lcd.setCursor(x, 0);
lcd.write(255);
lcd.write(6);
lcd.write(6);
lcd.setCursor(x, 1);
lcd.write(7);
lcd.write(7);
lcd.write(5);
}
void custom6()
{
lcd.setCursor(x, 0);
lcd.write(8);
lcd.write(6);
lcd.write(6);
lcd.setCursor(x, 1);
lcd.write(3);
lcd.write(7);
lcd.write(5);
}
void custom7()
{
lcd.setCursor(x, 0);
lcd.write(1);
lcd.write(1);
lcd.write(2);
lcd.setCursor(x + 1, 1);
lcd.write(8);
}
void custom8()
{
lcd.setCursor(x, 0);
lcd.write(8);
lcd.write(6);
lcd.write(2);
lcd.setCursor(x, 1);
lcd.write(3);
lcd.write(7);
lcd.write(5);
}
void custom9()
{
lcd.setCursor(x, 0);
lcd.write(8);
lcd.write(6);
lcd.write(2);
lcd.setCursor(x + 2, 1);
lcd.write(255);
}
void loop() {
unsigned long currmillis = millis();
//detect button pressing
if (digitalRead(buttonHr) == HIGH) {
delay(25);
hrs = hrs + 1;
updateHrs();
//update AMPM on button press
if (hrs == 12) {
updateAMPM();
}
delay(400);
}
if (digitalRead(buttonMin) == HIGH) {
delay(25);
mins = mins + 1;
//Serial.println(mins);
updateMin();
delay(400);
}
if (currmillis - prevmillis > 999) {
//lcd.clear();
prevmillis = currmillis;
if (secs < 10) {
lcd.setCursor(12, 0);
lcd.print(secs);
lcd.setCursor(11, 0);
lcd.print(0);
}
else {
lcd.setCursor(11, 0);
lcd.print(secs);
}
//display minutes
if (secs == 0) {
mins = mins + 1;
updateMin();
}
//get new seconds from system time
secs = (millis() / milliDivSecs) % 60; // divide by 1000 and mod by 60 gives seconds from milliseconds
}
}
//update min function
//calls the update am apm funciton and the update hours functions.
void updateMin() {
if (mins > 59) {
hrs = hrs + 1;
updateHrs(); //update hours then
if (hrs == 11 && mins > 59) {
updateAMPM();
}
mins = 0; //reset mins
lcd.setCursor(8, 0);
lcd.print("00");
}
if (mins < 10) {
lcd.setCursor(9, 0);
}
else {
lcd.setCursor(8, 0);
}
lcd.print(mins);
}
//update hour function
void updateHrs() {
//display hours - needs fixing for am pm
if (hrs > 12) {
//reset to 1
hrs = 1;
}
if (hrs < 10) {
lcd.setCursor(5, 0);
lcd.print(" ");
lcd.setCursor(6, 0);
}
else {
lcd.setCursor(5, 0);
}
lcd.print(hrs);
}
void updateAMPM() {
if (isAM) {
isAM = false;
lcd.setCursor(14, 0);
lcd.print("PM");
}
else {
isAM = true;
lcd.setCursor(14, 0);
lcd.print("AM");
}
}
[/code]