# Complete Guide How to Creating a Single-Digit Display using Arduino

In this project, we’ll Complete Guide How to Creating a Single-Digit Display utilizing Arduino step by step complete process.for this you have to need to know about arrays.

## ≡ What are Arrays

An array is a set of variables or values grouped together so that they can be referenced as a whole. If dealing with lots of related data, you’ll find it a good idea to utilize arrays to hold your data organized.

Defining an Array
Every item in an array is called an element. For example, suppose six float variables include temperatures taken over the last six hours instead of giving them all separate names, we can set an array called temperatures with six elements like this:

float temperatures;

We can also include values if defining the array. If we do that, we don’t want to define the array size. Here’s an example:

float temperatures[]={11.1, 12.2, 13.3, 14.4, 15.5, 16.6};

Notice that this time we took explicitly define the size of the array in the square brackets ([]); alternately, its size is inferred based on the number of components set by the values inside the curly brackets ({}).

##### Referring to Values in an Array

We add the elements in an array beginning from the left and starting from 0; the temperatures[] array has elements numbered 0 to 5. We can refer to individual values in an array by inserting the number of the element in the square brackets. For example, to develop the first element in temperatures[] (currently 16.6) to 12.34, we would utilize this:

temperatures = 12.34;

Writing to and Reading from Arrays

Array read/write show, we show values to and reading values from an array of five elements. The first for loop in the sketch writes a random number into each of the array’s elements, and the second for loop retrieves the elements and presents them in the Serial Monitor.

```void setup()
{
Serial.begin(9600);
}
int array;    // define our array of five integer elements
void loop()
{
int i;
Serial.println();
for ( i = 0 ; i < 5 ; i++ )   // write to the array
{
array[i] = random(10);      // random numbers from 0 to 9
}
for ( i = 0 ; i < 5 ; i++ )   // display the contents of the array
{
Serial.print("array[");
Serial.print(i);
Serial.print("] contains ");
Serial.println(array[i]);
}
delay(5000);
}```

Figure 1 shows the output of this sketch in the Serial Monitor. Now you know how to work with binary numbers, shift registers, and arrays,so you put that knowledge to run. In the next section, we’ll wire up amazing digital number displays.

## ≡ Seven-Segment LED Displays

LEDs are fun, but there are limits to the kinds of data that can be presented with individual lights. In this section, we’ll create working with numeric digits in the form of seven-segment LED displays, as shown in Figure 2. Figure 2

These displays are excellent for displaying numbers, and that’s why you’ll find them worked in digital alarm clocks, speedometers, and other numeric displays. Every module in a seven-segment LED display consists of eight LEDs.

The modules are also possible in different colors. To reduce the number of pins utilized by the display, all of the anodes or cathodes of the LEDs are joined together and are called common-anode or common-cathode, respectively. in Our projects will utilize common-cathode modules.

The display’s LEDs are marked A to G and DP. There is an anode pin for each LED segment, and the cathodes are joined to one common cathode pin.

The layout of seven-segment LED displays is always described as shown in Figure 2, with LED segment A at the top, B to its right, and so on. So, for example, if you needed to display the number 7, then you would apply current to segments A, B, and C.

The pins on every LED display module can vary, depending on the manufacturer, but they always follow the necessary pattern given in Figure 2. If you utilize one of these modules, always get the datasheet for the module from the retailer to help save you time determining which pins are which.

We’ll utilize the schematic symbol shown in Figure 3 for our seven-segment LED display modules.  ## ≡ Controlling the LED

We’ll control the LED display utilizing, by joining pins A through DP to the shift register outputs Q0 to Q7. utilize the matrix presented in Table 1 as a guide to help you determine which segments to turn on and off to display a special number or letter.

The top row in the matrix is the shift register output pin that examines the segments in the second row. Each row below this gives the digit that can be displayed with the corresponding binary and decimal value to send to the shift register.

Table 1. Display Segment Matrix
 SR Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Segment A B C D E F G DP Decimal 1 1 1 1 1 1 252 1 1 1 96 2 1 1 1 1 1 218 3 1 1 1 1 1 242 4 1 1 1 1 102 5 1 1 1 1 1 182 6 1 1 1 1 1 1 190 7 1 1 1 224 8 1 1 1 1 1 1 1 254 9 1 1 1 1 1 1 246 A 1 1 1 1 1 1 238 B 1 1 1 1 1 62 C 1 1 1 1 156 D 1 1 1 1 1 122 E 1 1 1 1 1 158 F 1 1 1 1 142 Figure 4 Displaying the digit 7

For example, to display the digit 7 as shown in Figure 4, we require to turn on LED segments A, B, and C, which agree to the shift register outputs Q0, Q1, and Q2. Therefore, we will send the byte B1110000 into the shift register (with shift out set to LSBFIRST) to turn on the first three outputs that match the desired LEDs on the module.

In the next example, we’ll build a circuit that displays, in turn, the digits 0 through 9 and then the letters A through F. The cycle returns with the decimal-point LED turned on.

## ≡  Creating a Single-Digit Display using Arduino

#### for Creating a Single-Digit Display using Arduino you have to need flowing Hardware

1. One 74HC595 shift register IC
2. One common-cathode seven-segment LED display
3. Eight 560 Ω resistors (R1 to R8)
5. Various connecting wires
6. Arduino and USB cable

## ≡ Schematic

The schematic is shown in Figure 5. Figure 5 v

If wiring the LED module to the shift register, LED pins A through G join to pins Q0 through Q6, respectively, and DP connects to Q7.

## ≡ Sketch

we store the decimal values (see Table 1) in the int digits[] array. In the void loop, we send those values to the shift register in regular order at 1 and then return the method with the decimal point on by adding 1 to the value sent to the shift register at 2:

```#define DATA  6                       // connect to pin 14 on the 74HC595
#define LATCH 8                       // connect to pin 12 on the 74HC595
#define CLOCK 10                      // connect to pin 11 on the 74HC595

// set up the array with the segments for 0 to 9, A to F (from Table 6-2)
int digits[] = {252, 96, 218, 242, 102, 182, 190, 224, 254, 246, 238, 62, 156,
122, 158, 142};

void setup()
{
pinMode(LATCH, OUTPUT);
pinMode(CLOCK, OUTPUT);
pinMode(DATA, OUTPUT);
}

void loop()
{
int i;
for ( i = 0 ; i < 16 ; i++ )   // display digits 0-9, A-F
{
digitalWrite(LATCH, LOW);
1 shiftOut(DATA, CLOCK, LSBFIRST, digits[i]);
digitalWrite(LATCH, HIGH);
delay(250);
}
for ( i = 0 ; i < 16 ; i++ )   // display digits 0-9, A-F with DP
{
digitalWrite(LATCH, LOW);
2 shiftOut(DATA, CLOCK, LSBFIRST, digits[i]+1); // +1 is to turn on the DP bit
digitalWrite(LATCH, HIGH);
delay(250);
}
}```