PCBX
Published

Key-Controlled Seven-Segment Digital Timer Simulation

Meet the Key-Controlled Seven-Segment Digital Timer: easy-to-use, visible from a distance, perfect for classrooms, labs, and cooking.

BeginnerFull instructions provided57
Key-Controlled Seven-Segment Digital Timer Simulation

Things used in this project

Story

Read more

Schematics

cover_Es9qmY9WvV.png

Code

Digital Timer

Arduino
int segmentPins[] = {2, 3, 4, 5, 6, 7, 8};
int buttonPins = A0;

byte numbers[10] = {
    0x3F, // 0
    0x06, // 1
    0x5B, // 2
    0x4F, // 3
    0x66, // 4
    0x6D, // 5
    0x7D, // 6
    0x07, // 7
    0x7F, // 8
    0x6F  // 9
};

int counter = 0;

void setup() {
    for (int i = 0; i < 7; i++) {
        pinMode(segmentPins[i], OUTPUT);
    }
    pinMode(buttonPins, INPUT);
}

void loop() {
    if(digitalRead(buttonPins) == HIGH){
        displayNumber(counter);
        counter = (counter + 1) % 10;
        delay(1000);
    }
}

void displayNumber(int num) {
    for (int i = 0; i < 7; i++) {
        digitalWrite(segmentPins[i], numbers[num] & (1 << i));
    }
}

Credits

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

Comments

Please log in or sign up to comment.