MicroController Pros Home Page My Account  Cart Contents  Checkout  

****Note: We no longer process and ship international orders. Only orders from USA and Canada are now accepted.****
You can place international orders for our products on E-Bay. Just copy the item's title description from our website and paste it into the search box on E-Bay and place your order there.

  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 Software
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
2-pin Female Connector Harnesses, Pack of 10, with 10 Wires
2-pin Female Connector Harnesses, Pack of 10, with 10 Wires
US$10.00
Bestsellers
01. 2x5 (10-pin) 0.05" pitch IDC Connector Flat Ribbon Cable, 20cm
02. 2x5 (10-pin) 0.05" pitch IDC Connector Flat Ribbon Cable, 12cm
03. 5-pin Press-Fit Header Strip, Breakaway Pins, 2.54mm Pitch
04. Parallel to USB Adapter: Connect USB printer to LPT port
05. 2x10 (20-pin) 0.1" pitch IDC Connector Flat Ribbon Cable, 15cm
06. 8-pin Press-Fit Header Strip, Breakaway Pins, 2.54mm Pitch
07. USB Universal In-Circuit Programmer PIC AVR ARM MSP 8051 EEPROM
08. 2x5 (10-pin) 0.1" pitch IDC Connector Flat Ribbon Cable, 15cm
09. ARM JTAG Debugger & Programmer, parallel port
10. Power Supply 3-12V DC, U.S. plug, 6 connection tips
Reviews more
This is a great little board that allowed us to get a very s ..
5 of 5 Stars!
  Tuesday 19 March, 2024   List of all our Products

Copyright © 2003-2017 MicroController Pros LLC
Powered by osCommerce