CSC270 Stopwatch Display

From CSclasswiki
Jump to: navigation, search


We wired our display as shown in the diagram below. For complete tutorial on 7-segment display:

Display wiring.png

The 7-segment Arduino display only has 12 pins:

  • 4 digit pins that turn each digit ON/OFF (D1, D2, D3, D4)
  • 7 segment pins for each segment of the digit (A, B, C, D, E, F, G)
  • 1 pin for decimal point (DP)


Each segment pin turns ON/OFF a corresponding segment in all 4 digits. The labeling of the segments is shown below. SevSeg library that we used to display our digits works by looping through all the segments really fast and for every segment toggling the digits that contain them. To a human eye it looks like all the segments are on at once.


Code we used to test the display:

#include <SevSeg.h>

SevSeg sevseg; 

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 updateWithDelaysIn = true;
  byte hardwareConfig = COMMON_CATHODE; 
  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
void loop(){