Skip to content

Qmaker-programmer/segDisplay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

segDisplay

A lightweight and easy-to-use C++ library for controlling Common Cathode 7-segment displays in Arduino environments.


🚀 Features

  • Object-Oriented Design: Create multiple display instances easily without cluttering your code.
  • Flexible Pin Assignment: Map any digital or analog pin to specific segments using a custom order.
  • Manual Segment Control: Turn specific segments on or off individually using the .set() method.
  • Direct Numeric Display: Print digits from 0 to 9 automatically using the .num() method.

🛠️ Recommended Connections (For Arduino Uno)

Display Pin (Segment) Arduino Uno Digital Pin
Pin G Digital 2
Pin F Digital 3
Pin A Digital 4
Pin B Digital 5
Pin E Digital 6
Pin D Digital 7
Pin C Digital 8
Pin DP (Decimal) Digital 9

⚠️ Note: Remember to connect the common cathode pin (GND) of your display to the Arduino Ground line using an appropriate current-limiting resistor (e.g., 220 ohms).


💻 Quick Start Example

Here is how easily you can implement a basic counter from 0 to 9 using this library:

#include <segDisplay.h> 

// Instantiate the display matching your hardware wiring:
// segDisplay name(G, F, A, B, E, D, C, DP);
segDisplay display1(2, 3, 4, 5, 6, 7, 8, 9);

void setup() {
    // Automatically configures pins 2 to 9 as OUTPUT
    display1.begin();
}

void loop() {
    // Continuous loop counting from 0 to 9
    for (int i = 0; i <= 9; i++) {
        display1.num(i); // Update the digit on the display
        delay(1000);     // Wait for 1 second before the next number
    }
}

🔧 Library API Reference

1. Constructor

segDisplay(uint8_t g, uint8_t f, uint8_t a, uint8_t b, uint8_t e, uint8_t d, uint8_t c, uint8_t dp);

Initializes the class object with your custom pin assignments.

2. .begin()

void begin();

Configures all the assigned pins internally as OUTPUT. Must be placed inside your void setup().

3. .num()

void num(int numero);

Prints a specific number from 0 to 9. Passing any other value will completely clear/turn off the display for safety.

4. .set()

void set(bool g, bool f, bool a, bool b, bool e, bool d, bool c, bool dp);

Gives you direct raw control over each individual segment. Pass 1 to turn on a segment or 0 to turn it off.


👥 Authors & License

About

A lightweight library for controlling 7-segment displays.

Resources

License

Stars

Watchers

Forks

Contributors

Languages