Simple Arduino UNO counter

Description of the Arduino 7-Segment Display Code
This Arduino code controls a 7-segment display to show numbers from 0 to 9 based on a button press. The segmentPins array defines the pins connected to each segment of the display, while the buttonPins variable is set to an analog pin that reads the button state. The numbers array contains the byte representations of digits 0 through 9, which are used to activate the appropriate segments of the display.
In the setup() function, the segment pins are configured as outputs, and the button pin is set as an input. The loop() function continuously checks if the button is pressed. When the button is pressed, it calls the displayNumber() function to show the current counter value on the 7-segment display. The counter increments with each button press, looping back to 0 after reaching 9, creating a simple counting mechanism.
This project is perfect for beginners interested in learning about Arduino programming, 7-segment display interfacing, and button input handling. It demonstrates fundamental concepts in electronics and coding, making it an excellent hands-on project for aspiring hobbyists.
SCHEMATIC:

CODE:
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));
}
}
- Arduino projects
- 7-segment display tutorial
- Arduino button input
- Electronics projects for beginners
- Arduino programming for beginners
- Digital display projects
- DIY electronics projects
- 7-segment display interfacing
- Counter project with Arduino
- Arduino display projects
You may also like
- Arduino UNO Blink IoT Guide — ESP32 Arduino, Blynk App & Arduino IDE Code
- Blynk IoT with Arduino UNO & ESP32 — Free Arduino IDE, Library & App Tutorial
- Frequency counter Arduino UNO
- Top 5 IoT Projects with Arduino UNO & ESP32 — Blynk, Wi-Fi & Smart Home Tutorials (2026)
- How to Control LEDs Using Blynk and Arduino Uno: A Complete Guide
EmbedLab Team
Embedded systems engineer and educator. Writes weekly tutorials at EmbedLab to help beginners ship real hardware.
Related projects

Arduino UNO Blink IoT Guide — ESP32 Arduino, Blynk App & Arduino IDE Code
Complete Arduino UNO Blink IoT guide using ESP32 Arduino and the Blynk app: free Arduino IDE code, Arduino library and LED wiring — the easiest Arduino IoT project for beginners to download and try online.

Blynk IoT with Arduino UNO & ESP32 — Free Arduino IDE, Library & App Tutorial
Complete Blynk IoT tutorial for Arduino UNO and ESP32 Arduino: install the Arduino IDE, add the Blynk Arduino library, wire LEDs, LCD and sensors, and control everything from the Blynk app over Wi-Fi — a free, beginner-friendly Arduino IoT project.

Frequency counter Arduino UNO
Description of the Arduino Frequency Measurement Code This Arduino code utilizes a Liquid Crystal Display (LCD) to measure and display the frequency of a digital signal connected to an input pin. The

Top 5 IoT Projects with Arduino UNO & ESP32 — Blynk, Wi-Fi & Smart Home Tutorials (2026)
The top 5 IoT projects every Arduino UNO and ESP32 maker should build in 2026 — Blynk IoT control, Wi-Fi blink, ESP-WROOM-32 dev board guide, ESP32 Proteus 8 simulation and an Arduino smart home parking system. Each pick links to the full tutorial with free Arduino IDE code, library and wiring.
How to Control LEDs Using Blynk and Arduino Uno: A Complete Guide
How to Control LEDs Using Blynk and Arduino Uno: A Complete Guide Controlling LEDs remotely using Blynk and an Arduino Uno is a simple yet powerful project for IoT (Internet of Things) enthusia



