Introduction: A Simple Counter

This project was developed with an Arduino Micro and a Common Anode (CA) 4x7-Segment Display only, and so it can count from 0000 to 9999.

Step 1: List of Materials

1 Arduino Micro, 5V

1 Common Anode, 4x7-Segment Display

1 USB-A to USB-B Micro Cable

Step 2: ​Identifying the Display’s Pins

Check the display’s pins before beginning to connect them to your Arduino Micro.

Step 3: Connecting Display and Arduino Pins Respectively

CA 4x7-Segment Display & Corresponding Arduino Micro Pins

Pin 1(E)-----------------A2

Pin 2(D)-----------------A1

Pin 3(DP)NC-----------NC

Pin 4(C)------------------15

Pin 5(G)------------------14

Pin 6(dig. 4)---------------4

Pin 7(B)------------------10

Pin 8(dig. 3)---------------7

Pin 9(dig. 2)---------------8

Pin 10(F)-------------------6

Pin 11(A)-------------------5

Pin 12(dig. 1)-------------16

Step 4: Uploading the Code

Once done the connections between the 4x7-segment display and the Arduino, you can already upload the following code:

//A Simple Counter

#define A 5

#define B 10

#define C 15

#define D A1

#define E A2

#define F 6

#define G 14

// Pins driving common anodes

#define CA1 16

#define CA2 8

#define CA3 7

#define CA4 4

// Pins for A B C D E F G, in sequence

const int segs[7] = {5, 10, 15, A1, A2, 6, 14};

// Segments that make each number

const byte numbers[10] = {192, 249, 164, 176, 153, 146, 130, 248, 128, 144};

void setup() {

pinMode(5, OUTPUT);

pinMode(10, OUTPUT);

pinMode(15, OUTPUT);

pinMode(A1, OUTPUT);

pinMode(A2, OUTPUT);

pinMode(6, OUTPUT);

pinMode(14, OUTPUT);

pinMode(16, OUTPUT);

pinMode(8, OUTPUT);

pinMode(7, OUTPUT);

pinMode(4, OUTPUT);


void loop() {

for (int digit1=0; digit1 < 10; digit1++) {

for (int digit2=0; digit2 < 10; digit2++) {

for (int digit3=0; digit3 < 10; digit3++) {

for (int digit4=0; digit4 < 10; digit4++) {

unsigned long startTime = millis();

for (unsigned long elapsed=0; elapsed < 600; elapsed = millis() - startTime) {















void lightDigit1(byte number) {

digitalWrite(CA1, LOW);

digitalWrite(CA2, LOW);

digitalWrite(CA3, LOW);

digitalWrite(CA4, HIGH);



void lightDigit2(byte number) {

digitalWrite(CA1, LOW);

digitalWrite(CA2, LOW);

digitalWrite(CA3, HIGH);

digitalWrite(CA4, LOW);



void lightDigit3(byte number) {

digitalWrite(CA1, LOW);

digitalWrite(CA2, HIGH);

digitalWrite(CA3, LOW);

digitalWrite(CA4, LOW);



void lightDigit4(byte number){

digitalWrite(CA1, HIGH);

digitalWrite(CA2, LOW);

digitalWrite(CA3, LOW);

digitalWrite(CA4, LOW);



void lightSegments(byte number){

for (int i = 0;i < 7;i++) {

int bit = bitRead(number, i);

digitalWrite(segs[i], bit);




mwacuff made it!(author)2017-02-05

Thanks for your post. The Arduino Micro shown in the photos is a different hardware version from the one I just purchased (see photo). It looks like your Micro has 26 pins, whereas mine has 34 pins. So I'm concerned that the pin mappings in your Instructable aren't going to work with this new version.

Where you've indicated named pins, I'm sure those will map correctly. But where you've indicated pin numbers for the Micro, I'm not so sure. Can you help?

Thanks again!

braulio777 made it!(author)2017-02-24

I'm sorry, I didn't realize before I wrote Arduino Micro instead of Arduino Pro-Micro.

braulio777 made it!(author)2017-02-23

Definitely, it's an Arduino Pro-Micro.

mwacuff made it!(author)2017-02-05

On further inspection, I see that the module used in the Instructable is actually a "Pro Micro" board, and not an Arduino Micro, which explains the pin differences. Further, I found documentation on the Pro Micro on Sparkfun.

About This Instructable




More by braulio777:Arduino Nano Multiplication/Division SignsA Simple Arduino Clock3 Digit Arduino Binary Counter
Add instructable to: