Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Controlled Seven-Segment Display Counter

Image of Arduino UNO Controlled Seven-Segment Display Counter

Circuit Documentation

Summary

This circuit consists of an Arduino UNO microcontroller connected to a seven-segment display. The Arduino UNO is programmed to control the display, counting from 0 to 9 with a one-second delay between each digit. The seven-segment display is a common anode type, meaning the segments are turned on by setting the corresponding pins to LOW.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. Seven Segment Display (Wokwi Compatible)

    • Description: A common anode seven-segment display.
    • Pins: G, F, COM.2, B, A, E, D, COM.1, C, DP

Wiring Details

Arduino UNO

  • 5V connected to COM.1 of the Seven Segment Display
  • D8 connected to G of the Seven Segment Display
  • D7 connected to F of the Seven Segment Display
  • D6 connected to E of the Seven Segment Display
  • D5 connected to D of the Seven Segment Display
  • D4 connected to C of the Seven Segment Display
  • D3 connected to B of the Seven Segment Display
  • D2 connected to A of the Seven Segment Display

Seven Segment Display (Wokwi Compatible)

  • COM.1 connected to 5V of the Arduino UNO
  • G connected to D8 of the Arduino UNO
  • F connected to D7 of the Arduino UNO
  • E connected to D6 of the Arduino UNO
  • D connected to D5 of the Arduino UNO
  • C connected to D4 of the Arduino UNO
  • B connected to D3 of the Arduino UNO
  • A connected to D2 of the Arduino UNO

Code Documentation

Arduino Sketch

/*
 * This Arduino sketch controls a seven-segment display to count from 0 to 9
 * with a one-second delay between each digit. The display is a common anode
 * type, so the segments are turned on by setting the corresponding pins to LOW.
 */

const int segmentPins[] = {2, 3, 4, 5, 6, 7, 8}; // Pins connected to segments A-G

// Digit patterns for common anode 7-segment display (0-9)
const byte digitPatterns[10] = {
  0b11000000, // 0
  0b11111001, // 1
  0b10100100, // 2
  0b10110000, // 3
  0b10011001, // 4
  0b10010010, // 5
  0b10000010, // 6
  0b11111000, // 7
  0b10000000, // 8
  0b10010000  // 9
};

void setup() {
  // Initialize segment pins as outputs
  for (int i = 0; i < 7; i++) {
    pinMode(segmentPins[i], OUTPUT);
  }
}

void loop() {
  for (int digit = 0; digit < 10; digit++) {
    displayDigit(digit);
    delay(1000); // Wait for 1 second
  }
}

void displayDigit(int digit) {
  byte pattern = digitPatterns[digit];
  for (int i = 0; i < 7; i++) {
    digitalWrite(segmentPins[i], (pattern & (1 << i)) ? HIGH : LOW);
  }
}

This code initializes the pins connected to the seven-segment display as outputs and then enters a loop where it displays digits from 0 to 9 with a one-second delay between each digit. The displayDigit function sets the appropriate segments to LOW to display the desired digit.