Thursday, December 6, 2007

Balinese Learn About 7-Segment Display

Project Description

In this project we will try to control a common anode 7-segment display using PIC 16F877 microcontroller. Assemble the circuit, write down the program for microcontroller and watch the 7-segment display.

Tools and Parts Needed


* PIC 16F877
* 20 Mhz Crystal Oscillator
* 33 pF Capacitor (2 units)
* 7-segment display
* 680 ohm resistor (8 units)
* Logic Probe
* Breadboard
* 5 Volt Power Supply

* MPLAB Software

Basic Theory


The Seven Segment Display is consists of seven LED named A through G. The LEDs are connected as common cathode or common anode. In this project we will use the common anode. Connect the common pin to +5 Vdc. In this way, a logic "1" at segment pin will turn the segment off, while a logic "0" at segment pin will turn the segment on. An optional LED is added as decimal point (DP).



Use MPLAB IDE to write, simulate and program the PIC 16F877. Please click on Microchip link to get a free MPAB software.

Experiment Steps

Step 1:

Assemble the Circuit on the Breadboard as picture follows



Please connect Port B to 680 ohm resister and seven segment display as follows:
pin 33 to A segment
pin 34 to B segment
pin 35 to C segment
pin 36 to D segment
pin 37 to E segment
pin 38 to F segment
pin 39 to G segment
pin 40 to DP segment

Step 2:


Program the PIC 16F877 as follows using MPLAB. This will display "1" at 7-segment. Make sure that column 1 is used for label only.

INCLUDE "P16F877.INC"

BSF STATUS, RP0
MOVLW 0X00
MOVWF TRISB

MOVLW 0X06
MOVWF ADCON1

BCF STATUS, RP0
MOVLW B'11111001'
MOVWF PORTB

SLEEP

END

3. Download it to the PIC.

4. Connect the circuit to power supply.

5. Watch the display

6. Please try to display number "2" to 9".

No comments: