# Arduino Fourteen Segment Display - شاشه من رقمين باستخدام اردوينو

72

1

## Introduction: Arduino Fourteen Segment Display - شاشه من رقمين باستخدام اردوينو

This instructables provides basic guidelines to make fourteen segment display, basically the goal is to:
▪ Learn how control many LEDs by using Arduino Nano.
▪ Understand how to program the fourteen segment to display numbers by using different code functions.

### Supplies:

Basic components:
1- Breadboard small size (2 units).
2- Leds (For one array we need 4 leds, so total we need 14 arrays x 4
LEDs = 56 LEDs).
3- Arduino nano (1 unit).
4- Jumper wires (male-male, male-female).

Basic tools:
1- Mini USB cable for Arduino (1 unit).
2- Arduino IDE software on PC.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Built the Circuit.

♧ To build fourteen segment display you should fix the LEDs on the breadboard in the form of No. 88 as the diagram shows.
♧ fourteen arrayes = each array is containing 4 LEDs.

## Step 2: Connection of the First Digit.

• Connect the common cathode for all LEDs together with GND in Arduino board.
• Connect positive cathode for each array with Arduino pin as show above.

## Step 3: Connection of the Second Digit.

♤ Once the circuit is ready, you will start doing some interesting experiments that can enhance your skills in writing the codesfor displaying any numbers of LEDs.

## Step 4: Exercise 1: Show a Number.

The goal is to show number 1 on the display of fourteen segment.

Arduino program code (Show number 1 on the display).
int ledA = 10;
int ledB = 9;
int ledC = 8;
int ledD = 7; // Seven segment connected with Arduino
int ledE = 6;
int ledF = 5;
int ledG = 4;
void setup() {
pinMode(ledA, OUTPUT);
pinMode(ledB, OUTPUT);
pinMode(ledC, OUTPUT);
pinMode(ledD, OUTPUT);
pinMode(ledE, OUTPUT);
pinMode(ledF, OUTPUT);
pinMode(ledG, OUTPUT);
}
void loop() {
digitalWrite(ledB, HIGH); // Number 1 is ON.
digitalWrite(ledE, HIGH);
}

## Step 5: Exercise 2: Show Number With Different Delays.

◆ The goal is generate numbers on display from 1 to 3 with different
delays.
◆ Main concept: How to control the speed of lighting in fast and slow speed by increasing and decreasing the delay time

Arduino program code (From 1 to 3 fast and slow sequence).
int ledA = 10;
int ledB = 9;
int ledC = 8;
int ledD = 7;
int ledE = 6;
int ledF = 5;
int ledG = 4;
int ledAA = A1;
int ledBB = A2;
int ledCC = A3;
int ledDD = A4;
int ledEE = A5;
int ledFF = 3;
int ledGG = 2;
void setup() {
pinMode(ledA, OUTPUT);
pinMode(ledB, OUTPUT);
pinMode(ledC, OUTPUT);
pinMode(ledD, OUTPUT);
pinMode(ledE, OUTPUT);
pinMode(ledF, OUTPUT);
pinMode(ledG, OUTPUT);
pinMode(ledAA, OUTPUT);
pinMode(ledBB, OUTPUT);
pinMode(ledCC, OUTPUT);
pinMode(ledDD, OUTPUT);
pinMode(ledEE, OUTPUT);
pinMode(ledFF, OUTPUT);
pinMode(ledGG, OUTPUT);
}

void loop() {
orderslow();
orderfast();
}
void number1() {
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledD, HIGH);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledBB, HIGH);
digitalWrite(ledEE, HIGH);
}

void number2() {
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledD, HIGH);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledAA, HIGH);
digitalWrite(ledBB, HIGH);
digitalWrite(ledCC, HIGH);
digitalWrite(ledFF, HIGH);
digitalWrite(ledGG, HIGH);
}
void number3() {
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledD, HIGH);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledAA, HIGH);
digitalWrite(ledBB, HIGH);
digitalWrite(ledCC, HIGH);
digitalWrite(ledEE, HIGH);
digitalWrite(ledFF, HIGH);

}

void orderslow() { //from 1 to 3 slow.
number1();
delay(500);
off();
number2();
delay(500);
off();
number3();
delay(500);
off();
}
void orderfast() { //from 1 to 3 FAST.
number1();
delay(100);
off();
number2();
delay(100);
off();
number3();
delay(100);
off();
}

## Step 6: Exercise 3: Show Even Numbers.

◆ The goal is to show even numbers (2, 4, 6).
◆ The main concept: How to control the generation of lighting LEDs to show the even numbers (2, 4, 6).

♧Arduino program code: (Show even numbers - Simple form).

void loop() {
even(); // put even function in void loop.
}

void even() { //Add void even to generate even numbers.
number2();
delay(800); //count in even mode.
off();
number4();
delay(800);
off();
number6();
delay(800);
off();
}

♧Arduino program code: (Show even numbers using WHILE function).

void loop() {
int n=0;
while (n<=98) { //while function generates even
numbers.
n=n+2;
show(n);
}
}
void show(int n) {
switch (n) {
case 1:
number1();
delay(500);
off();
break;
case 2:
number2();
delay(500);
off();
break;
case 3:
number3();
delay(500);
off();
break;
case 4:
number4();
delay(500);
off();
break;
case 5:
number5();
delay(500);
off();
break;
case 6:
number6();
delay(500);
off();
break;
}
}

## Step 7: Exercise 4: Show Odd Numbers

◆ The goal is generate odd numbers (1, 3, 5) on the display.
◆ The main concept: How to generate odd numbers (1, 3, 5) using the WHILE function.

♧ Arduino program code: Sequence of odd numbers.

void loop() {
int n=-1;
while (n<=5) { //change the function in void loop.
n=n+2;
show(n);
}
}

## Step 8: Exercise 5: Show Multiples of Number 5.

◆ The goal: Generate number 5, 10, 15 on display.
◆ The main concept: How to generate numbers (5, 10, 15) using the FOR function.

♧ Arduino program code: Show sequence numbers using FOR function.

void loop() {
int n=0;
for (int n=0; n<=95; n=n+5){
show(n);
}
}

## Step 9: Exercise 6: Show Fibonacci Numbers.

◆ The goal: Generate Fibonacci sequence numbers on display (1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89).
◆ The main concept: is knowing how to generate Fibonacci sequence numbers from 1 to 99 using FOR function. (See the above table)

Fn = Fn-1 + Fn-2, Where Fn = a,Fn-1 = b,Fn-2 = c

♧ Arduino program code: Fibonacci sequence using FOR function.

void loop() {
int b= 1;
int c= 0;
int a;
show(c);
show(b);
a= b+c;
for (int a=b+c; a<99; b=a) {
show(a);
c=b;
a=b+c;
}
}

## Step 10: Exercise 7: Show 1x1, 2x2, 3x3,...........nxn

◆ The goal: Generate sequence numbers (1x1, 2x2, 3x3..............nxn) on display.
◆ Main concept: How to generate the results of this type of sequence numbers on display using the WHILE function.

♧ Arduino program code:
void loop() {
int a;
a= 1;
while (a<99) {
show (a*a);
a=a+1;
}
}

## Step 11: Exercise 8: Show 1(2), 2(3), 3(4),.........n(n+1).

◆ The goal: generate sequence numbers (1(2), 2(3), 3(4).............n(n+1)) on display
◆ Main concept: How to generate the above on display by using WHILE function.

♧ Arduino program code: show sequence numbers using WHILE function.
void loop() {
int b= 2;
int c= 1;
int a;
a= b*c;
while (a<99) {
show (a);
c = c+1;
b = b+1;
a=b*c;
}
}

## Step 12: Exercise 9: Show 1(3), 4(6), 7(9) on Display.

◆ Goal: generate sequence numbers(1(3), 4(6), 7(9)) on display.
◆ Main concept: is knowing how to generate the above by using the WHILE function.

♧ Arduino program code: show sequence numbers using WHILE function.
void loop() {
int b= 1;
int c= 3;
int a;
a= b*c;
while (a<99) {
show (a);
c = c+3;
b = b+3;
a=b*c;
}
}

## Step 13: Exercise 10: Show (1)(2)(3), (2)(3)(4), (3)(4)(5),.........n(n+1)(n+2)

◆ Goal: generate sequence numbers((1)(2)(3), (2)(3)(4), (3)(4)(5),.........n(n+1)(n+2)) on display.
◆ Main concept: How to generate the above by using the WHILE function.

♧ Arduino program code: show sequence numbers using WHILE function.
void loop() {
int d= 1;
int b= 2;
int c= 3;
int a;
a= d*b*c;
while (a<99) {
show (a);
c = c+1;
b = b+1;
d = d+1;
a=d*b*c;
}
}

## Step 14: Exercise 11: Show (1)(2)(3)/(4)(5), (2)(3)(4)/(5)(6), (3)(4)(5)/(6)(7).......n(n+1)(n+2)/(n+3)(n+4)

◆ Goal: Generate sequence numbers (1)(2)(3)/(4)(5), (2)(3)(4)/(5)(6), (3)(4)(5)/(6)(7).......n(n+1)(n+2)/(n+3)(n+4) on display.
◆ Main concept: How to generate the above by using the WHILE function.

♧ Arduino program code: show sequence numbers using WHILE function.
void loop() {
int f= 1;
int e= 2;
int d= 3;
int b= 4;
int c= 5;
int a;
a= d*f*e/b*c;
while (a<99) {
show (a);
e = e+1;
f = f+1;
c = c+1;
b = b+1;
d = d+1;
a = d*f*e/b*c;
}
}

9 2.7K
102 22K
34 10K