7 Segment Display With Arduino
by Jalp Desai in Circuits > Arduino
60 Views, 0 Favorites, 0 Comments
7 Segment Display With Arduino
Welcome! This tutorial is about the seven-segment display and how it works with Arduino. A seven-segment display gets its name because it’s made up of seven parts. You’ve probably seen these displays on alarm clocks, toys, counters, and scoreboards. These displays can show numbers from 0 to 9 and some letters from A to Z. In this guide, we’ll explain step by step how a seven-segment display works and how to use it with Arduino. This knowledge will be super helpful for your projects!
Supplies
- Arduino UNO board x 1
- Seven-segment display x 1
- Breadboard x 1
- Jumper wires x 10
- 320 OHM Resistor x 2
Setting Up the Circuit
First, take your Arduino board and connect it to the breadboard using jumper wires. Place the 7-segment display on the breadboard carefully. Then, connect the pins of the 7-segment display to the Arduino using jumper wires. Add resistors between the Arduino and the display pins to protect the display from too much current. Now, plug in the USB cable to the Arduino to power it up. Make sure the wires are connected properly, following the right connections for the 7-segment display to work. Once done, you should see the circuit starting to come to life.
Code
/*How to use a seven-segment LED display.
created by the SriTu Tech team.
Read the code below and use it for any of your creations.
Home Page
*/
byte pin[] = {2, 3, 4, 5, 6, 7, 8, 9};//arduino pin array
int number[9][8] = {//number array
{1, 1, 0, 0, 0, 1, 1, 1},//1
{0, 0, 1, 0, 0, 0, 1, 0},//2
{1, 0, 0, 0, 0, 0, 1, 0},//3
{1, 1, 0, 0, 0, 1, 0, 0},//4
{1, 0, 0, 0, 1, 0, 0, 0},//5
{0, 0, 0, 0, 1, 0, 0, 0},//6
{1, 1, 0, 0, 0, 0, 0, 1},//7
{0, 0, 0, 0, 0, 0, 0, 0},//8
{1, 1, 0, 0, 0, 0, 0, 0},//9
};
void setup() {
for (byte a = 0; a < 8; a++) {
pinMode(pin[a], OUTPUT);//define output pins
}
}
void loop() {
for (int a = 0; a < 9; a++) {
for (int b = 0; b < 8; b++) {
digitalWrite(pin[b], number[a][b]);//display numbers
}
delay(500);//delay
}
}