Beruflich Dokumente
Kultur Dokumente
to LED
The driver software can be developed using any programming language like
Assembly, C etc.
The resistor is important in LED interfacing to limit the flowing current and
avoid damaging the LED and/or MCU.
Interfacing LED with PIC16F887
The PIC16F Development Board has eight numbers of point LEDs, connected with I/O Port lines (PORTx.0 –
PORTx.7) to make port pins high. Here, we have connected LEDs with PORT B.
PIC CONNECTIONS:
LED.0 PORTx.0
LED.1 PORTx.1 Connect Any one PORT from LED’s will be turned
PORTA, PORTB, PORTC, ON and OFF at 500ms
LED.2 PORTx.2 PORTD with JP3 (LED interval.
LED.3 PORTx.3 Section) via FRC cable
LED.4 PORTx.4
LED.5 PORTx.5
LED.6 PORTx.6
LED.7 PORTx.7
CIRCUIT DIAGRAM:
The Interfacing LED with PIC16F877A program is very simple and straight forward, that uses a delay procedure loop
based software.
C PROGRAM CODE :
The HEX code is stored into the MCU in a place called Flash
memory.
CODE EXPLAINATION:
// library file
• This defines the oscillator frequency. The value 8000000 means its frequency is 8MHz.
• Assembly code is processed line by line. The speed at which is line is processed is the microcontroller's instruction cycle.
• The while loop will execute infinite times. The LEDs connected to PORTB will keep on blinking with 1 second delay
(1s=1000ms). This process is repeated until the program is aborted.
• This causes the blinking of the LED. The speed of the Blinking LED can be increased or decreased by varying the
delay value.
0xff will give high output from each eight line of Port B. This will assign input HIGH to Port B.
To have a delay of 1000ms. So high logic will pass from port B pins for 1000ms.
• This line will make the output from port B get down to 0V, i.e. logic ‘0’. It is to be considered that until the value in
PORTB is changed, the output from the port will also not change.
• So the output will drop from 5V (logic 1) to 0V (logic 0) only when this line is executed.
Output:
LED will be turned OFF and ON in the interval of 1 sec.
THE END