Complete Guide LED Binary Number Display in Arduino

LED Binary Number Display

In this project, we’ll Complete Guide LED Binary Number Display in Arduino step by step complete process.for this you have to need to know about binary numbers.

≡ A Short brief in a binary number

Most of them are learning to count utilizing the base-10 system, but computers (and the Arduino) count utilizing the binary number system. Binary numbers consist of just 1s and 0s—for example, 1010001110. In binary, each digit from right to left represents 2 to the power of the column number in which it looks . The results in each column are then joined to learn the value of the number.

For example, analyze the binary number 11111111, as shown in Table 1. To change the number 11111111 in binary to base 10, we calculate the totals in each column as noted in the bottom row of the table:

128 + 64 + 32 + 16 + 8 + 4 + 2 + 1

It is 255. A binary number including eight columns (or bits) holds 1 byte of data; 1 byte of data can have a numerical value within 0 and 255. The leftmost bit is assigned to as the Most Significant Bit (MSB), and the rightmost is the Least Significant Bit (LSB).

Binary numbers are excellent for storing certain kinds of data, such as on/off patterns for LEDs, true/false settings, and the state utilizes digital outputs. Binary numbers are the building blocks of all types of data in computers.

Table 1. Binary to base-10 number conversion example

1286432168421Base 10

What is Byte Variables

One method we can store binary numbers is by utilizing a byte variable. For example, we can build the byte variable outputs utilizing the following code:

byte outputs = B11111111;

The B in front of the number says Arduino to read the number as a binary number (in this case, 11111111) instead of its base-10 equivalent of 255. 

Example of Binary number demonstration 

byte a;

  void setup()

  void loop()
    for ( int count = 0 ; count < 256 ; count++ )
      a = count;
      Serial.print("Base-10 = ");
1     Serial.print(a, DEC);
      Serial.print(" Binary = ");
2     Serial.println(a, BIN);

We present byte variables as base-10 numbers utilizing DEC 1 or as binary numbers utilizing BIN 2 as part of the Serial.print() function. After uploading the sketch, you should see the output in the Serial Monitor similar to that shown in Figure 1.

74HC595 schematic symbol Figure 3. 74HC595 schematic symbol


16 pins on our shift register:

Pins 15 and 1 to 7 are the eight output pins that we manage (labeled Q0 to Q7, respectively).

Q7 outputs the first bit sent to the shift register, down to Q0, which outputs the last.

Pin 8 connects to GND.

9 no pin is “data out” and is utilized to send data to different shift registers if one is present.

10 no pin is ever joined to 5 V (for example, the 5 V connector on the Arduino).

11 no pin and 12 are named clock and latch.

13 no pin is called output enable and is normally joined to GND.

14 no pin is for incoming bit data sent from the Arduino.

16 no pin is utilized for power: 5 V from the Arduino.

To give you a sense of the way pins are oriented, the semicircular notch on the left end of the body of the shift register IC shown in Figure 3 lies within pins 1 and 16.

The pins are numbered sequentially around the body in a counterclockwise way, as shown in Figure 4, the schematic for our LED binary number display.

≡ Sketch Binary Number Display in Arduino

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

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

void loop()
   int i;
   for ( i = 0; i < 256; i++ )
     digitalWrite(LATCH, LOW);
     shiftOut(DATA, CLOCK, MSBFIRST, a);
     digitalWrite(LATCH, HIGH);

we began the three pins joined to the shift register as outputs in void setup() and then add a loop in void loop() that counts from 0 to 255 and repeats. The magic lies inside the loop. If we send a byte of data (for example, 240, or B11110000) to the shift register in the for loop, three things happen.

The latch pin 12 is set to LOW. This is preparation for setting output pin 12 to HIGH, which latches the data to the output pins after shift out has completed its task.

We send the byte of data from Arduino digital pin 6 to the shift register and show the shift out function from which method to interpret the byte of data. For example, if you chose LSBFIRST, then LEDs 1 to 4 would turn on and the others would turn off. If you utilized MSBFIRST, then LEDs 5 to 8 would turn on and the others would turn off.

Lt last, the latch pin 12 is set to HIGH (5 V is applied to it). This tells the shift register that all the bits are shifted in and ready. At this point, it alters its output to match the data taken.

All Arduino tutorial available Click here


 27 total views,  1 views today