First, explain to us what you mean by “it doesn’t work with my display”?I am building a digital clock with an arduino and a 4 digit 7 segment display, and I need to change the minutes every 60 seconds by +1. If i put delay it doesnt work with my display. What should I do?
#include "SevSeg.h"
SevSeg sevseg;
int s=0000;
int mix;//all in minutes
int m=0;//minutes
int h=0;//hours
void setup() {
m=0;
h=0;
Serial.begin(9600);
// put your setup code here, to run once:
byte numDigits=4;
byte digitPins[]={10,11,12,13};
byte segmentPins[] = {9,2,3,5,6,8,7,4};
bool resistorsOnSegments = true;
bool updateWithDelaysIn = true;
byte hardwareConfig = COMMON_CATHODE;
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
}
void loop() {
int x;
mix=m+h*60;
m=mix%60;
h=(mix-m)/60;
if(h<10){
x=1;
}
if(h>=10){
x=2;
}
s=m+h*100;
sevseg.setNumber(s,x);
sevseg.refreshDisplay();
mix=mix+1;
delay(60000);
}
It shows 0.0 which is correct, but than it doesnt show 0.1......If you delete the delay() statement and replace it with
while(-1);what does the display show?
Ok, so we know the display works. Now replace the delay command, but instead of a parameter of 60000, use 2000...It shows 0.0 which is correct, but than it doesnt show 0.1......
I didnt see that you typed while(-1) , i just saw what if u deleted delay() , when i put while(-1) it doesnt show anything, and when i delete delay and dont put anything it shows 0.0Ok, so we know the display works. Now replace the delay command, but instead of a parameter of 60000, use 2000...
Thank you, I will look it upI have been reviewing the library documentation for SevSeg, Your last mistake and what I’ve learned may explain your problem.
You need to call .refreshDisplay() repeatedly. Look at the comments in the documentation examples. By using delay(), you don’t refresh the display often enough.
You need to change your code to only increment your counter once every 60 seconds and still call .refreshDisplay() every time loop() is executed. To do this, you’ll need to use millis() and check to see if 60 seconds have elapsed. That way, the refresh function can be called during the 60 second period.
by Duane Benson
by Aaron Carman
by Jake Hertz