Skip to content

Arduino library for nice and easy usage of a seven-segment display (single-digit type)

License

Notifications You must be signed in to change notification settings

NeMaksym/easy-seven-seg

Repository files navigation

License: MIT author

Easy SevenSeg

Arduino library that significantly simplify connection process and usage of a seven-segment display (single-digit type)

Supported digits

zero one two three four five six seven eight nine

Supported letters

a b c d e f

Installation

Either use Library Manager

In Arduino IDE Sketch -> Include Library -> Manage Libraries.... Then find "Easy SevenSeg"

Or import as Zip

On GitHub repository Code -> Download Zip

In Arduino IDE Sketch -> Include Library -> Add .ZIP Library.... Then select downloaded archive

Usage

In code

#include "EasySevenSeg.h"   // Include

EasySevenSeg myDisplay;     // Initialize

myDisplay.begin();          // Begin (setups Arduino pins)

myDisplay.printDigit(1);    // Print 0 to 9
myDisplay.printLetter("A"); // Print A to F (accepts upper- and lowercase)

Display types

There are two types of seven-segment displays.

Look at the picture below. The display has 10 pins in total. Pins #3 and #8 are common. The other eight pins are responsible for a single segment each (yeah, it calls "seven-segment" mostly because of the historical reason).

Get back to the common pins. Depending on what they are we can distinguish two display types:

  • Common anode display (common pins are +).
    • It means, in order to highlight the segments, the common pins must be "+" (e.g., 5V or HIGH) and the segment pins must be "-" (e.g., GND or LOW)
  • Common cathode display (common pins are -).
    • It means, in order to highlight the segments, the common pins must be "-" (e.g., GND or LOW) and segment pins must be "+" (e.g., 5V or HIGH)

Note 1: The library is designed for the "common cathode" type. If anyone wants to implement a "common anode", you are welcome to make a pull request.

Note 2: Segments are simple LEDs under the hood. In order to keep them safe, don't forget to use resistors when connecting each of them to "+". 220Ω will be enough.

Display pinout

Connect to Arduino

The begin() method setups appropriate Arduino pins as OUTPUT.

Default pins

By default (if no arguments passed to the method) you may use the following pins:

  • display pin 1 == 1A on Arduino
  • display pin 2 == 2A on Arduino
  • display pin 4 == 4A on Arduino
  • display pin 5 == 5A on Arduino
  • display pin 6 == 6 on Arduino
  • display pin 7 == 7 on Arduino
  • display pin 9 == 9 on Arduino
  • display pin 10 == 10 on Arduino

Custom pins

On the other hand, you may set up your own pin values. Just pass them to the begin(int 1pin, ... int 10pin) method. Keep in mind, pins #3 and #8 are omitted, since they are common (see "display types" above).

About

Arduino library for nice and easy usage of a seven-segment display (single-digit type)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages