Lab05.docx

  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Lab05.docx as PDF for free.

More details

  • Words: 615
  • Pages: 4
Microprocessors and Microcontrollers Lab 5

Lab No. 5 Seven Segment Display Interfacing Objectives:  

7 segment display interfacing and programming To understand the multiplexing technique

Introduction: A seven segment display, as its name indicates, is composed of seven elements. Individually on or off, they can be combined to produce simplified representations of the numerals. A single LED is used inside one segment to radiate light through it. If cathodes of all the LEDs are common, this type of display is called common cathode and for common anode type display, anode of all LEDs are common and connected to the common pin.

Multiplexing: Multiplexing is required when we want to interface more than one displays with microcontroller. If we interface them normally, they will require lots of I/O ports. In multiplexing, only one display is kept active at a time but we see all of them active. For multiplexing all the displays are connected in parallel such that if you activate any segment, say ‘a’ the ‘a’ segment of all displays glows up. But we can switch ON and OFF the “common” line of the displays with the Microcontroller pins. So if we wish to light up the ‘a’ segment of display 1 we simply switch on display 2 first by applying ground level (for common cathode display) at the common pin of the display and then send a high signal on the I/O pin connected to segment ‘a’ to lit it.

Page 5

Microprocessors and Microcontrollers Lab 5 // PORTA.0 = a // PORTA.3 = d // PORTA.6 = g

PORTA.1 = b PORTA.4 = e PORTA.7 = dot

PORTA.2 = c PORTA.5 = f

a _____ f | g | b |_____| e | | c dot |_____| . d ______________________________ |No.| . g f e d c b a |____________________________ | 0 | 0 0 1 1 1 1 1 1 = 0x3F | | 1 | 0 0 0 0 0 1 1 0 = 0x06 | | 2 | 0 1 0 1 1 0 1 1 = 0x5B | | 3 | 0 1 0 0 1 1 1 1 = 0x4F | | 4 | 0 1 1 0 0 1 1 0 = 0x66 | | 5 | 0 1 1 0 1 1 0 1 = 0x6D | | 6 | 0 1 1 1 1 1 0 1 = 0x7D | | 7 | 0 0 0 0 0 1 1 1 = 0x07 | | 8 | 0 1 1 1 1 1 1 1 = 0x7F | | 9 | 1 0 0 1 1 1 1 1 = 0x6F | |____________________________

Sketch for two digit 7 segment display: Count from 00 to 99 unsigned char Seven_Segment[]={0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D,0x7D, 0x07, 0x7F, 0x6F}; unsigned char i = 0; void setup() { DDRD = 0xFF; // OUPTPUT PORTS FOR SEVEN SEGMENT DISPLAYS pinMode(8,HIGH); // SELECT LINE(pin# 08) FOR UNITS DISPALY pinMode(9,HIGH); // SELECT LINE(pin# 09) FOR TENS DISPLAY }

Page 6

Microprocessors and Microcontrollers Lab 5

void loop() { Display(i);

// Displays two digit value on 7 segments

i++; if(i > 99) i = 0; }

void Display(unsigned char n) { unsigned char units, tens, x; tens = n/10; units = n%10;

// Separate tens from a two digit number // Separate units from a two digit number

// Select one display to show units value digitalWrite(8,LOW); // Display units PORTD=Seven_Segment[units]; delay(500); // Select second display to show tens value digitalWrite(9,LOW); // Display tens PORTD= Seven_Segment[tens]; delay(500); }

Page 7

Microprocessors and Microcontrollers Lab 5

Schematic:

Lab Task: Show hexadecimal numbers from 00 to FF on two seven segment display

Page 8