Hello everyone. I have 4 seven-segment indicators. I would like to make a clock based on them, but without using time sensors. That is, only the arduino and indicators + clock setting buttons. Is it even possible to do this? Do you have any examples of sketches? Thanks
Since Arduino's can count milliseconds, I suppose it's possible. I have no idea how accurate it will be, but I guess we won't know until you try.
Let us know how it works out.
Try the following Stopwatch (Fig-1):
Figure-1:
Example Sketch to update only the Second Field. You can expand it to update Minute Field.
#include<SevSeg.h>
SevSeg sevSeg; //create object sevSeg
int numberToShow = 00;
unsigned long prMillis = 0;
void setup()
{
pinMode(2, INPUT_PULLUP);
byte segDPins[] = {8, 9, 10, 11, 12, 13, 6, 7}; //DPin8 = seg-a, …, DPin-7 = seg-p
byte ccDPins[] = {A2, A3}; //DPin-2 = cc2, DPin-3 = cc3, ...
sevSeg.begin(COMMON_CATHODE, 2, ccDPins, segDPins, false, false, false, true);
sevSeg.setNumber(numberToShow, 0, LOW);
//---------------------------------
}
void loop()
{
while (millis() - prMillis < 1000)
{
sevSeg.refreshDisplay();
}
numberToShow++;
if (numberToShow == 60)
{
numberToShow = 0;
}
sevSeg.setNumber(numberToShow, 0, LOW);
prMillis = millis();
}
I Have moved your topic to an appropriate forum category.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose. How to get the best out of this forum
The section you posted in said "Do not post in this section"
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
Yes. You can make a clock by configuring the timers of ATmega328P.
Here is an example: https://www.instructables.com/Arduino-Digital-Clock-Without-RTC-Real-Time-Clock-/
But it will be less accurate than using an RTC IC.
If you ever consider making a clock using RTC and Arduino, you can consider this:
DS1307 Arduino based Digital Clock in Proteus - The Engineering Projects
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
