Arduino/C2/Seven-Segment-Display/English

From Script | Spoken-Tutorial
Revision as of 10:44, 4 January 2018 by Nirmala Venkat (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Title of script: Seven Segment Display

Author: Nirmala Venkat

Keywords: Arduino UNO board, Arduino IDE, Compile and upload, Seven Segment Display, Video tutorials

Visual Cue Narration
Slide 1:


Welcome to the Spoken Tutorial on Seven Segment Display.
Slide 2:

Learning objectives

In this tutorial, we will learn to:
  • Connect a Seven Segment Display to Arduino board and
  • Write a program to display digits from 0 to 4 on the Seven Segment Display.
Slide 3:

Pre-requisites

To follow this tutorial, you should have basic knowledge of:
  • Electronics and
  • C or C++ programming language
Slide 4:

System Requirement

To record this tutorial, I am using:
  • Arduino UNO Board
  • Ubuntu Linux operating system 14.04 and
  • Arduino IDE
Slide 5:

External Devices

We will also require some external devices such as:
  • Seven-Segment Display
  • 220 ohm Resistor
  • Breadboard and
  • Jumper Wires
Show the image:

Seven-segment display

[[Image:]]
Slide:6

Seven Segment Display

The seven-segment display has seven LEDs arranged in the shape of the digit eight.


There are two types of displays:

  • common anode and
  • common cathode seven segment display.
Point to the diagram In the common cathode seven-segment display, pins a, b, c, d, e, f, g and dot must be connected to +5V.

The two COM pins must be connected to ground (GND).


Point to the diagram The common anode seven-segment display is the exact opposite.

Here pins a, b, c, d, e, f, g and dot must be connected to GND and the two COM pins must be connected to +5V.

Now let us see the connection circuit details.
Show the image:


circuit.png

In this experiment, we will be using the common cathode seven-segment display.
Point to the image according to narration. Pins a, b, c, d, e, f and g of the seven-segment display are connected to pins 2, 3, 4, 5, 6, 8 and 9 of Arduino,respectively.

Note that we didn't connect to pin 7.

The two common (COM) pins are connected to the ground through the resistors.

This is shown here in the black color wire.

The resistor value should be greater than 220 ohms.

Dot is left unconnected because it is not used in this experiment.

Show the real connection This is the live setup of the connection, as shown in the circuit diagram.
Switch to Arduino IDE Now we will write a program in the Arduino IDE.

So let’s switch to the Arduino IDE.

First we will write a program to blink the LEDs in the seven segment display.
// To blink the LEDs on SSD


#define a 2//connecting segment a to PIN2

#define b 3// connecting segment b to PIN3

#define c 4// connecting segment c to PIN4

#define d 5// connecting segment d to PIN5

#define e 6// connecting segment e to PIN6

#define f 8// connecting segment f to PIN8

#define g 9// connecting segment g to PIN9


Type the code shown here.


We have assigned the segment names to the Arduino pins.


These help us to remember easily which Arduino ports are connected to the display’s segments.

This code is available in the code file link of this tutorial for your convenience.

You can download and use it.

void setup()

{

pinMode(a, OUTPUT);

pinMode(b, OUTPUT);

pinMode(c, OUTPUT);

pinMode(d, OUTPUT);

pinMode(e, OUTPUT);

pinMode(f, OUTPUT);

pinMode(g, OUTPUT);

}

In the void setup function, we will use the function pinMode to configure the pin to output mode.
void loop()

{

digitalWrite(a,HIGH);

digitalWrite(b,HIGH);

digitalWrite(c,HIGH);

digitalWrite(d,HIGH);

digitalWrite(e,HIGH);

digitalWrite(f,HIGH);

digitalWrite(g,HIGH);

delay(1000);

digitalWrite(a,LOW);

digitalWrite(b,LOW);

digitalWrite(c,LOW);

digitalWrite(d,LOW);

digitalWrite(e,LOW);

digitalWrite(f,LOW);

digitalWrite(g,LOW);

delay(1000);

}


Now we will write the code for void loop.


Void loop function will blink the LED of the seven segment display.


The code is same as the ones in the earlier tutorials.

Click on compile and upload button on the toolbar We will now compile and upload the program.
Point to the output in the video


Now we can see that all the LEDs in the seven segment are glowing.
Next, we will modify the program to display some digits.
Show the slide:


Highlight g in the diagram.

[[Image:]]

Say, we want to display the digit zero.

The LEDs of segment 'g' should be low and all other LED segments should be high.


To display '1', b and c segments should be high and the other LEDS should be low.


Likewise, we can write the code for all other digits also.

Switch back to Arduino IDE. Let us switch back to the Arduino IDE.
Copy and paste the code to display 0 to 4

void loop()

{

//ZERO

digitalWrite(a,HIGH);

digitalWrite(b,HIGH);

digitalWrite(c,HIGH);

digitalWrite(d,HIGH);

digitalWrite(e,HIGH);

digitalWrite(f,HIGH);

digitalWrite(g,LOW);

delay(1000);

//ONE

digitalWrite(a,LOW);

digitalWrite(b,HIGH);

digitalWrite(c,HIGH);

digitalWrite(d,LOW);

digitalWrite(e,LOW);

digitalWrite(f,LOW);

digitalWrite(g,LOW);

delay(1000);

Change the code in the void loop function, as shown here.


I have written the code to display the digits 0,1,2,3 and 4.

Click on compile and upload button on the tool bar Let us now compile and upload the program.
Show the output in the video You can see that the digits 0 to 4 are displayed, with a delay of 1 second between them.
This brings us to the end of this tutorial. Let us summarize.
Slide 11:

Summary

In this tutorial, we learnt to
  • Connect a Seven-segment Display to Arduino board and
  • Write a program to display digits from 0 to 4 on a seven-segment display.


Slide 12:

Assignment

Try doing the following assignment.
  • Change the same program to display the digits 5,6,7,8 and 9.
  • Compile and upload the program and
  • Observe the digits displayed in the seven segment display.


Slide 13:

About Spoken Tutorial project


The video at the following link summarizes the Spoken Tutorial project.

Please download and watch it.

Slide 14:

Spoken Tutorial workshops

The Spoken Tutorial Project Team:
  • conducts workshops and
  • gives certificates.

For more details, please write to us.

Slide 15:

Forum for specific questions

Please post your timed queries in this forum.
Slide 16:

Acknowledgement


Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.

More information on this mission is available at

this link.

This tutorial has been contributed by Spoken Tutorial Project, IIT Bombay.  

Thanks for watching.

Contributors and Content Editors

Nancyvarkey, Nirmala Venkat