MicroController Pros Home Page
My Account  Cart Contents  Checkout  
  Store » PCAM+ 8051 Tutorial 5 My Account  |  Cart Contents  |  Checkout   
Quick Find
 
Enter keywords to find the product you are looking for in the Quick Find field above

or use
Advanced Search
Categories
Accessory Boards->
8051->
ADI Blackfin
Arduino->
ARM->
Atmel AVR->
Cypress PSoC
Freescale->
FTDI->
Locktronics
Microchip PIC->
MIPS
Parallax->
Renesas
Silicon Labs
ST Microelectronics->
Texas Instruments->
Tibbo->
Books->
Displays->
E-Blocks->
EEPROM/EPROM/FLASH
Embedded Ethernet->
Embedded Software->
I/O Modules->
Parts & Components->
Pick & Place Tools
Programmable Logic (PLD)
Prototype PCBs->
Robotics
ROM/Flash Emulators
Test & Measurement->
Tutorial CD-ROMs
Universal Programmers->
Wireless->
Information
Intro to Embedded Tools
Embedded News Digest
Useful Resources
Shipping & Returns
Warranty & Liability
Privacy Notice
Conditions of Use
Contact Us
PCAM+ 8051 Tutorial 5: Seven-Segment Display Interface

Back to PCAM+ page.


Back to Chapter 4

7-Segment Display Interface with 8051 Microcontrollers

Seven-segment displays are nothing more than well arranged LEDs inside a box — actually eight of them when you count the decimal point. As such, the interfacing code should be as simple as interfacing a row of LEDs. Indeed it is simple, though the complexity is in multiplexing displays.

Here, we'll write a program that will display the number 4321 on the seven-segment LED displays of the PCAM+ board.

First, make these connections using the jumper wires, but be sure to use the D1 etc. pins on the side of the seven-segment LEDs and not the ones with the same names used previously for the single-row LED examples.

  • Connect P2.0 from the microcontroller to pin D1 of the seven-segment LEDs
  • Connect P2.1 from the microcontroller to pin D2 of the seven-segment LEDs
  • Connect P2.2 from the microcontroller to pin D3 of the seven-segment LEDs
  • Connect P2.3 from the microcontroller to pin D4 of the seven-segment LEDs
  • Likewise, connect P3.0 through P3.7 to pins "a" through "•" on the other side of the seven-segment LEDs

Enter the following code in 8051IDE:

MOV P2,#00000000B

MAIN:
    LCALL SHOW
    SJMP MAIN

SHOW:
        MOV P2,#00001000B
        LCALL ONE
        LCALL DELAY

        MOV P2,#00000100B
        LCALL TWO
        LCALL DELAY

        MOV P2,#00000010B
        LCALL THREE
        LCALL DELAY

        MOV P2,#00000001B
        LCALL FOUR
        LCALL DELAY
RET

ZERO:
MOV P3,#0C0H
RET

ONE:
MOV P3,#0F9H
RET

TWO:
MOV P3,#0A4H
RET

THREE:
MOV P3,#0B0H
RET

FOUR:
MOV P3,#99H
RET

FIVE:
MOV P3,#092H
RET

SIX:
MOV P3,#82H
RET

SEVEN:
MOV P3,#0F8H
RET

EIGHT:
MOV P3,#80H
RET

NINE:
MOV P3,#90H
RET

DELAY:
        MOV R5,#1D
        LOOP1:
                MOV R6,#25D
        LOOP2:
                MOV R7,#100D
        DELAY_LOOP:
                DJNZ R7,$
                DJNZ R6,LOOP2
                DJNZ R5,LOOP1
RET

Assemble and download the code to the PCAM+ board as usual.

Proceed to Chapter 6


Back to PCAM+ page.

Shopping Cart more
0 items
What's New? more
Ultrasonic Sensor (Outdoor, IP67), XL-MaxSonar-WRA1 (MB7070)
Ultrasonic Sensor (Outdoor, IP67), XL-MaxSonar-WRA1 (MB7070)
US$157.47
Specials more
Atmel AVR STK500 Compatible Programmer, parallel port
Atmel AVR STK500 Compatible Programmer, parallel port
US$13.93
US$5.90
Bestsellers
01. PIC16F877A-I/P Microcontroller, 40 DIP, 20 MHz
02. PIC16F628A-I/P Microcontroller, 18 DIP, 20 MHz
03. LCD 4-mux, 7 digits x 14 segments, progress bar, arrows
04. Atmel ATtiny2313-20PU AVR Microcontroller, 20 DIP, 20 MHz
05. LCD 4-mux, 7.1 digits x 7 segments, progress bar, arrows
06. USB Universal In-Circuit Programmer PIC AVR ARM MSP 8051 EEPROM
07. ARM JTAG Debugger & Programmer, parallel port
08. Power Supply 3-12V DC, US/UK/Euro/AU Plugs, 100-240VAC
09. Power Supply 3-12V DC, U.S. plug, 6 connection tips
10. Atmel AVR JTAG In-Circuit Debugger & Programmer, USB
Reviews more
Universal Development Board 8051/ARM/AVR/PIC/dsPIC/PSoC: UNI-DS6
I just got the development board and have tried examples on ..
5 of 5 Stars!
  Tuesday 02 September, 2014   List of all our Products

Copyright © 2003-2014 MicroController Pros LLC
Powered by osCommerce