Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
PCBX
Published

Building an Interactive Seven-Segment Display with Arduino

Transform your projects with an interactive seven-segment display using Arduino! Engage users through dynamic visuals and control.

BeginnerFull instructions provided160

Things used in this project

Story

Read more

Schematics

97d53356444b4dde9655efb4718f6c82_WmSOKuja20.png

Code

Untitled file

Arduino
const int Pin_a = 7;
const int Pin_b = 6;
const int Pin_c = 5;
const int Pin_d = 10;
const int Pin_e = 11;
const int Pin_f = 8;
const int Pin_g = 9;
const int Pin_p = 4;

int numTable[10][8] = {
    // a  b  c  d  e  f  g  dp
    {1, 1, 1, 1, 1, 1, 0, 0},     // 0
    {0, 1, 1, 0, 0, 0, 0, 0},     // 1
    {1, 1, 0, 1, 1, 0, 1, 0},     // 2
    {1, 1, 1, 1, 0, 0, 1, 0},     // 3
    {0, 1, 1, 0, 0, 1, 1, 0},     // 4
    {1, 0, 1, 1, 0, 1, 1, 0},     // 5
    {1, 0, 1, 1, 1, 1, 1, 0},     // 6
    {1, 1, 1, 0, 0, 0, 0, 0},     // 7
    {1, 1, 1, 1, 1, 1, 1, 0},     // 8
    {1, 1, 1, 1, 0, 1, 1, 0},     // 9
};

void setup() {
    for (int i = 4; i <= 11; i++) {
        pinMode(i, OUTPUT); // Set pins 4 to 11 as output mode
    }
}

void loop() {
    for (int i = 0; i < 10; i++) { // Display numbers 0 to 9 in sequence
digitalWrite(Pin_a, numTable[i][0]); // Set the level for pin a
        digitalWrite(Pin_b, numTable[i][1]); // Set the level for pin b
        digitalWrite(Pin_c, numTable[i][2]); // Set the level for pin c
        digitalWrite(Pin_d, numTable[i][3]); // Set the level for pin d
        digitalWrite(Pin_e, numTable[i][4]); // Set the level for pin e
        digitalWrite(Pin_f, numTable[i][5]); // Set the level for pin f
        digitalWrite(Pin_g, numTable[i][6]); // Set the level for pin g
        digitalWrite(Pin_p, numTable[i][7]); // Set the level for pin dp
        delay(1000);
    }
}

Credits

PCBX

PCBX

15 projects • 3 followers
Customer Success: Your one-stop solution for PCB and PCBA services, plus component sourcing. Enjoy FREE online simulation and EDA.

Comments