I am attempting to make an Arduino counter using a 4 digit 7 segment display. The problem I am encountering is the display flickers. I am using an Arduino Uno and 5641AS digit display (so common cathode). Here is my program:
#include "SevSeg.h"
SevSeg sevseg;
int buttonPress{}; // Variable used in Serial monitor, simulates button press to increment counter
void setup(){
byte numDigits = 4;
byte digitPins[] = {10, 11, 12, 13};
byte segmentPins[] = {9, 2, 3, 5, 6, 8, 7, 4};
bool resistorsOnSegments = true;
bool updateWithDelays = false;
byte hardwareConfig = COMMON_CATHODE;
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
sevseg.setBrightness(90);
Serial.begin(9600);
sevseg.setNumber(0);
sevseg.refreshDisplay();
}
void loop(){
static int number = 0;
if (Serial.available() > 0) { // Serial monitor input for buttonPress
buttonPress = Serial.read();
}
Serial.println("The value of buttonPress is: ");
Serial.println(buttonPress);
if (buttonPress == 10){ // Increment counter if buttonPress Serial monitor input = 10
number += 15;
buttonPress = 0;
sevseg.setNumber(number); // Display the number on 4 digit 7 segment display
}
sevseg.refreshDisplay(); // Refresh display
}
I suspect this issue has to do with sevseg.refreshDisplay()
, I have tried moving it in the program with no avail. My wiring is correct, as the program displays the correct digits. Thank you!
1234
only ... does it still flicker