Go Down

Topic: RTC single digit 7-segment display clock  (Read 236 times) previous topic - next topic

JRUSCH

Hello,
I'm relatively new to Arduino and microcontrollers in general. Currently I'm studying Robotics and Embedded systems and the current course I am in is requiring a project that I've been working on for a bit. I would like to turn in a finished functional product, but I'm having issues sorting everything out. I have about 2 weeks from today to finish up and turn in the assignment. It doesn't necessarily have to work as this is an exercise in creative thinking/RSA. But, I would like to prove success if possible.

I'm attempting to create a single digit clock and using a secondary RGB LED with color indicating place of the digit in a HH:MM time format.

I've got both the 7-segment and LED working.

I'm using a datalogger/RTC shield from adafruit to attempt to get the RTC time. But, I'm having a problem getting the time from the RTC (PCF8523) and displaying that to the 7 -segment. The current sketch I have I am able to do a count up/down. But I guess I'm unclear as to how to code the correct function to get the time and display it to the seven segment. Any guidance would be appreciated.

Paul__B

I'm attempting to create a single digit clock and using a secondary RGB LED with color indicating place of the digit in a HH:MM time format.
Hmmm.  Sounds somewhat uninspiring but nevertheless!

OK, let's get going.  We will agree not to give you code because it is your assignment, but will make suggestions on your code.

So, we need the circuit diagram (but note many people here are allergic to "Fritzing" diagrams and want proper schematics  :smiley-lol: ).  And we need your working code regarding getting "both the 7-segment and LED working" and your non-working code, posted according to the forum instructions.

A photograph of the whole arrangement, taken outside in bright daylight but not full sun so that everything can actually be seen would also be nice.  :smiley-cool:

gilshultz


Why not start by defining the problem with specifications.  What is the expected outcome. Purchase the Arduino cookbook and read it, this will give you some basics. also use the online tutorials and videos available, there are many good ones on this web site.  At this point you will be able to define the problem and may have already solved it.
This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

JRUSCH

#3
Mar 01, 2020, 05:41 am Last Edit: Mar 01, 2020, 05:46 am by JRUSCH
Sorry that it may be trivial to some, but I'm just starting out so it is interesting to me none the less...lol.

This is the code that I'm currently using to get some activity:

/ One digit 7 segment LED display demo.
// Displays digit 0 - 9 and decimal point

int segPins[] = {6, 5, 2, 3, 4, 7, 8, 9, 10, 11, 12};   // { a b c d e f g . red blue green)
//red =10;  // lights red on RGB
//green = 12; //lights green on RGB
//blue =11; // lights blue on RGB

byte segCode[14][11] = {
//  a  b  c  d  e  f  g  . red blue green
 { 1, 1, 1, 1, 1, 1, 0, 0, 1, 1},  // 0 + lights magenta
 { 0, 1, 1, 0, 0, 0, 0, 0},  // 1
 { 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0},  // 2 + lights blue only
 { 1, 1, 1, 1, 0, 0, 1, 0},  // 3
 { 0, 1, 1, 0, 0, 1, 1, 0},  // 4
 { 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0},  // 5 + lights red only
 { 1, 0, 1, 1, 1, 1, 1, 0},  // 6
 { 1, 1, 1, 0, 0, 0, 0, 0},  // 7
 { 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1},  // 8 + lights green only
 { 1, 1, 1, 1, 0, 1, 1, 0},  // 9
 { 0, 0, 0, 0, 0, 0, 0, 1},   // .
};


void displayDigit(int digit)
{
 for (int i=0; i < 11; i++)
 {
   digitalWrite(segPins, segCode[digit]);
 }
}

//***************************************************************************
//******************************************************************************
void setup()
{
 for (int i=0; i < 11; i++)
 {
   pinMode(segPins, OUTPUT);
 }

}

//******************************************************************************
//******************************************************************************
void loop()
{
  for (int n = 0; n < 14; n++)    // display digits 0 - 9 and decimal point
 {
    displayDigit(n);
    delay(1000);
 }

}

I've modified it for the RGB.

The biggest issue is I have no clue how to incorporate the correct code for getting the time from the RTC and then getting that to the seven segment.

Here is the only diagram I was able to create: This is using a breakout rather than the shield which I am usinghttps://www.circuito.io/app?components=512,10820,11021,375026,821989


And here is a video of everything operating.https://photos.app.goo.gl/kJmgdZtgoLGRpvFT7https://photos.app.goo.gl/kJmgdZtgoLGRpvFT7

Here is  a photo, although without the RGB included:
https://photos.app.goo.gl/ezw7zSGKB9kPBvj47

Paul__B

Oops!

Didn't read the instructions on posting the code!

Fritzing diagram is missing the segment resistors on the 7-segment display!  Schematic would - as I said before - be preferred.  :smiley-roll:

JRUSCH

Well, appreciate the limited "help" offered but this has been as effective as I originally anticipated. I loath forums for specifically this very reason. I had a simple question- asking for some "guidance".....point me in the right direction. That's all I needed. But, what I get is tedium, procedural red-tape, and still no closer after two days of checking here for an answer. Thanks, but no thanks.....I'll just do what I've always done and search google.

Paul__B

Being "precious" is not going to get you far here and I venture to say, in the wider world either.

There are extremely good reasons for specifying how to post your code; if you troubled to look at your posting, you might even notice.  :smiley-roll:

Go Up