Counter 0-9 with 7 segments display and Arduino Uno.jpg

In this example I propose a simple simulation with Tinkercad of a circuit that creates a counter from 0 to 9 with a 7-segment display, programmed using Arduino Uno. The display is of the common cathode type.

The sketch that I propose to you is really working. This is the link: https://www.tinkercad.com/things/6ok3zL0QW2L. It is based on a look-up table made with an array where I have coded the digits of the numbers to be shown on the display.
I used port registers based programming and I choosed the ATMega 328 pin group called port D which is 8 bit and is convenient for managing an LED display. Here you can find information about Arduino port registers: https://www.arduino.cc/en/Reference/PortManipulation.

It is important that when you load the sketch in the Arduino FLASH memory, you momentarily disconnect pins 0 and 1, because they are used by the USB as serial TX and RX, otherwise the loading fails.

This is the sketch:

byte numero [10]={B00111111, B00000110, B01011011, B01001111, B01100110, B01101101, B01111101, B00000111, B01111111, B01101111};

int i=0;

void setup()
{
   DDRD = B11111111;
}

void loop()
{
   PORTD = numero[i];
   delay(500);
   i++;
   if (i>9)
      i=0;
}


Advertising

Advertising

Advertising

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.