A few years ago I had an Arduino Duemilanove paired with a DS3231 and running on a 1602 based 4x20 LCD (humblebrag this was just after chronodot came out and I couldn't find any libraries for it, so I looked at DS1307 examples and rolled my own for the DS3231 to display date, time, etc and even read the onboard temp sensor it used for the temperature compensated crystal /humblebrag) unfortunately a fire ravaged my apt complex destroying everything (and on the 10th anniversary of 9/11 of all dates) including my PC, Arduino, along with all my components and code
enough of the sob story though, I've recently acquired a new Arduino Uno kit and decided I'd give it another go
I have a 4 digit common anode 7seg display, I'm using Sparkfun's SevSeg library. I also have a DS1307 based RTC that's using the library suggested in Arduino's playground Time catagory.
The problem I'm having is trying to figure out how to display the time on the seven segment display. The examples on the SevSeg library are somewhat beyond my brain's ability, and I haven't been able to find any 7seg code that I can read and understand.
What I'm looking to do is write to each char of the display separately with the ability to add a decimal to whichever one I need because I'll eventually be adding a DS18b20 temp sensor if I can get this working. (as my brain can somewhat comprehend that method)
This is the code mash-up I've been trying to use just to figure out how this all works but it seems like the SevSeg library won't really allow me to do what I explained just above
sorry it has all the comments left intact from the original library but I thought it would help me understand but I don't
#include "SevSeg.h"
#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
//Create an instance of the object.
SevSeg myDisplay;
//Create global variables
//unsigned long time;
void setup()
{
int displayType = COMMON_ANODE; //Your display is either common cathode or common anode
/*
//This pinout is for a regular display
//Declare what pins are connected to the digits
int digit1 = 2; //Pin 12 on my 4 digit display
int digit2 = 3; //Pin 9 on my 4 digit display
int digit3 = 4; //Pin 8 on my 4 digit display
int digit4 = 5; //Pin 6 on my 4 digit display
//Declare what pins are connected to the segments
int segA = 6; //Pin 11 on my 4 digit display
int segB = 7; //Pin 7 on my 4 digit display
int segC = 8; //Pin 4 on my 4 digit display
int segD = 9; //Pin 2 on my 4 digit display
int segE = 10; //Pin 1 on my 4 digit display
int segF = 11; //Pin 10 on my 4 digit display
int segG = 12; //Pin 5 on my 4 digit display
int segDP= 13; //Pin 3 on my 4 digit display
*/
//This pinout is for OpenSegment PCB layout
//Declare what pins are connected to the digits
int digit1 = 17; //Pin 12 on my 4 digit display
int digit2 = 16; //Pin 9 on my 4 digit display
int digit3 = 15; //Pin 8 on my 4 digit display
int digit4 = 5; //Pin 6 on my 4 digit display
//Declare what pins are connected to the segments
int segA = 9; //Pin 11 on my 4 digit display
int segB = 8; //Pin 7 on my 4 digit display
int segC = 13; //Pin 4 on my 4 digit display
int segD = 12; //Pin 2 on my 4 digit display
int segE = 11; //Pin 1 on my 4 digit display
int segF = 7; //Pin 10 on my 4 digit display
int segG = 10; //Pin 5 on my 4 digit display
int segDP = 6; //Pin 3 on my 4 digit display
int numberOfDigits = 4; //Do you have a 1, 2 or 4 digit display?
myDisplay.Begin(displayType, numberOfDigits, digit1, digit2, digit3, digit4, segA, segB, segC, segD, segE, segF, segG, segDP);
myDisplay.SetBrightness(100); //Set the display to 100% brightness level
}
//timer = millis();
//}
void loop()
{
tmElements_t tm;
//Example ways of displaying a decimal number
char tempString[10]; //Used for sprintf
//sprintf(tempString, "%4d", time);
sprintf(tempString, "%4d", tm.Hour); //Convert deciSecond into a string that is right adjusted
//sprintf(tempString, "%d", tm.Hour, DEC); //Convert deciSecond into a string that is left adjusted
//sprintf(tempString, "%04d", tm.Second ); //Convert deciSecond into a string with leading zeros
//sprintf(tempString, "%4d", deciSecond * -1); //Shows a negative sign infront of right adjusted number
//sprintf(tempString, "%4X", deciSecond); //Count in HEX, right adjusted
//Produce an output on the display
myDisplay.DisplayString(tempString, 0); //(numberToDisplay, decimal point location in binary 1 2 4 8)
//delay(5);
}
//Other examples
//myDisplay.DisplayString(tempString, 0); //Display string, no decimal point
//myDisplay.DisplayString("-23b", 3); //Display string, decimal point in third position
//Check if 10ms has elapsed
/*if (millis() - timer >= 100)
{
timer = millis();
deciSecond++;
}
delay(5);
}
*/
Any help would be greatly appreciated and thank you for taking the time to read this book of a post