SevSeg

Examples

All images are generated from source code using the simulator.

Snippets

Template:

Comment Code snippet Display
 
disp.DisplayString("\x80\x81\x82\x84", 0);
_images/generated_disp_00.png
 
disp.DisplayString("\x88\x90\xA0\xC0", 0);
_images/generated_disp_01.png
 
disp.DisplayString("\xFF   ", 0);
_images/generated_disp_02.png
 
disp.DisplayString("\x00\x01\x02\x03", 0);
_images/generated_disp_03.png
 
disp.DisplayString("\x04\x05\x06\x07", 0);
_images/generated_disp_04.png
 
disp.DisplayString("\x08\x09\x0A\x0B", 0);
_images/generated_disp_05.png
 
disp.DisplayString("\x0C\x0D\x0E\x0F", 0);
_images/generated_disp_06.png
 
disp.DisplayString("1234", 0);
_images/generated_disp_07.png
 
disp.DisplayString("5678", 1);
_images/generated_disp_08.png
 
disp.DisplayString("90  ", 2);
_images/generated_disp_09.png
 
disp.DisplayString("ABCD", 3);
_images/generated_disp_10.png
 
disp.DisplayString("EFGH", 4);
_images/generated_disp_11.png
 
disp.DisplayString("IJKL", 5);
_images/generated_disp_12.png
 
disp.DisplayString("MNOP", 6);
_images/generated_disp_13.png
 
disp.DisplayString("QRST", 7);
_images/generated_disp_14.png
 
disp.DisplayString("UVWX", 8);
_images/generated_disp_15.png
 
disp.DisplayString("YZ  ", 9);
_images/generated_disp_16.png
 
disp.DisplayString("abcd", 10);
_images/generated_disp_17.png
 
disp.DisplayString("efgh", 11);
_images/generated_disp_18.png
 
disp.DisplayString("ijkl", 12);
_images/generated_disp_19.png
 
disp.DisplayString("mnop", 13);
_images/generated_disp_20.png
 
disp.DisplayString("qrst", 14);
_images/generated_disp_21.png
 
disp.DisplayString("uvwx", 15);
_images/generated_disp_22.png
 
disp.DisplayString("yz  ", 0);
_images/generated_disp_23.png
 
disp.DisplayString("!#$ ", 0);
_images/generated_disp_24.png
 
disp.DisplayString("%&()", 0);
_images/generated_disp_25.png
 
disp.DisplayString("'\"  ", 0);
_images/generated_disp_26.png
 
disp.DisplayString("*+,-", 0);
_images/generated_disp_27.png
 
disp.DisplayString("./  ", 0);
_images/generated_disp_28.png
 
disp.DisplayString("<=>?", 0);
_images/generated_disp_29.png
 
disp.DisplayString(":;@ ", 0);
_images/generated_disp_30.png
 
disp.DisplayString("\\[]^", 0);
_images/generated_disp_31.png
 
disp.DisplayString("_`|,", 0);
_images/generated_disp_32.png
 
disp.DisplayString("~   ", 0);
_images/generated_disp_33.png

Full programs

Program (SevSeg/Example/SevSeg_Counter/SevSeg_Counter.ino):

/*
 7-23-2012
 Spark Fun Electronics
 Nathan Seidle
 
 This code is originally based Dean Reading's Library deanreading@hotmail.com
 http://arduino.cc/playground/Main/SevenSegmentLibrary
 He didn't have a license on it so I hope he doesn't mind me making it public domain: 
 This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
 
 This example is a centi-second counter to demonstrate the use of the SevSeg library. To light
 the display you have to call myDisplay.DisplayNumber(#, decimalPlace) multiple times a second. Put this
 in the main loop.
 
 SparkFun has a large, 1" 7-segment display that has four digits.
 https://www.sparkfun.com/products/11408
 Looking at the display like this: 8.8.8.8. pin 1 is on the lower row, starting from the left. 
 Pin 12 is the top row, upper left pin.
 
 Pinout:
 1: Segment E
 2: Segment D
 3: Segment DP
 4: Segment C
 5: Segment G
 6: Digit 4
 7: Segment B
 8: Digit 3
 9: Digit 2
 10: Segment F
 11: Segment A
 12: Digit 1
 
 ToDo:
 Picture of setup with pin 1 indicator
 Covert big byte array to binary: http://arduino.cc/forum/index.php/topic,39760.0.html
 Measure current going through limiting resistors to make sure we're getting 20mA per segment per digit (should be 80mA for four digits)
 
 2264 bytes
 2134 bytes with new BigTime functions
 2214 if full DP support
 
 */

#include "SevSeg.h"

//Create an instance of the object.
SevSeg myDisplay;

//Create global variables
unsigned long timer;
int deciSecond = 0;

void setup()
{

  int displayType = COMMON_CATHODE; //Your display is either common cathode or common anode

  /*
  //This pinout is for a regular display
   //Declare what pins are connected to the digits
   int digit1 = 2; //Pin 12 on my 4 digit display
   int digit2 = 3; //Pin 9 on my 4 digit display
   int digit3 = 4; //Pin 8 on my 4 digit display
   int digit4 = 5; //Pin 6 on my 4 digit display
   
   //Declare what pins are connected to the segments
   int segA = 6; //Pin 11 on my 4 digit display
   int segB = 7; //Pin 7 on my 4 digit display
   int segC = 8; //Pin 4 on my 4 digit display
   int segD = 9; //Pin 2 on my 4 digit display
   int segE = 10; //Pin 1 on my 4 digit display
   int segF = 11; //Pin 10 on my 4 digit display
   int segG = 12; //Pin 5 on my 4 digit display
   int segDP= 13; //Pin 3 on my 4 digit display
   */

  //This pinout is for OpenSegment PCB layout
  //Declare what pins are connected to the digits
  int digit1 = 9; //Pin 12 on my 4 digit display
  int digit2 = 16; //Pin 9 on my 4 digit display
  int digit3 = 17; //Pin 8 on my 4 digit display
  int digit4 = 3; //Pin 6 on my 4 digit display

  //Declare what pins are connected to the segments
  int segA = 14; //Pin 11 on my 4 digit display
  int segB = 2; //Pin 7 on my 4 digit display
  int segC = 8; //Pin 4 on my 4 digit display
  int segD = 6; //Pin 2 on my 4 digit display
  int segE = 7; //Pin 1 on my 4 digit display
  int segF = 15; //Pin 10 on my 4 digit display
  int segG = 4; //Pin 5 on my 4 digit display
  int segDP= 5; //Pin 3 on my 4 digit display

  int numberOfDigits = 4; //Do you have a 1, 2 or 4 digit display?

  myDisplay.Begin(displayType, numberOfDigits, digit1, digit2, digit3, digit4, segA, segB, segC, segD, segE, segF, segG, segDP);
  
  myDisplay.SetBrightness(100); //Set the display to 100% brightness level

  timer = millis();
}

void loop()
{
  //Example ways of displaying a decimal number
  char tempString[10]; //Used for sprintf
  sprintf(tempString, "%4d", deciSecond); //Convert deciSecond into a string that is right adjusted
  //sprintf(tempString, "%d", deciSecond); //Convert deciSecond into a string that is left adjusted
  //sprintf(tempString, "%04d", deciSecond); //Convert deciSecond into a string with leading zeros
  //sprintf(tempString, "%4d", deciSecond * -1); //Shows a negative sign infront of right adjusted number
  //sprintf(tempString, "%4X", deciSecond); //Count in HEX, right adjusted

  //Produce an output on the display
  myDisplay.DisplayString(tempString, 3); //(numberToDisplay, decimal point location)

  //Other examples
  //myDisplay.DisplayString(tempString, 0); //Display string, no decimal point
  //myDisplay.DisplayString("-23b", 3); //Display string, decimal point in third position

  //Check if 10ms has elapsed
  if (millis() - timer >= 100)
  {
    timer = millis();
    deciSecond++;
  }

  delay(5);
}

GUI:

_images/generated_SevSeg_Counter.png

Signals:

_images/gtkwave_id0.png

Library size estimation

Program bytes Data bytes
2556 79

The size is calculated as a difference of example program and minimal program:

Library size = example program size - minimal program size

Table Of Contents

This Page