![]() | ||||||
|
PicBasic Experiments With The PIC16F877
| ||||||
|
This application shows how to use the PIC16F877 Port D to blink LEDs attached to the port-pins. The LED blink routine is pretty basic, but can be useful if you're a beginner, and it comes in handy to test your PIC programmer.
Figure 1 shows the schematic used for this experiment. The Port D I/O-pins are used in output mode to blink the LEDs attached to each port-pin. Here is the PicBasic code: ' PicBasic Pro program to blink all the LEDs on PORTD
i var byte ' Define loop variable
LEDS var PORTD ' Alias PORTD to LEDS
TRISD = %00000000 ' Set PORTD to all output
loop: LEDS = 1 ' First LED on
Pause 500 ' Delay for .5 seconds
For i = 1 to 7 ' Go through For..Next loop 7 times
LEDS = LEDS << 1' Shift on LED one to left
Pause 500 ' Delay for .5 seconds
Next i
Goto loop ' Go back to loop and blink LED forever
End
YES -- I know it's simple, but we all started blinking LEDs at some point....;o] Get PicBasic:
| ||||||
|
Copyright ©
1999-2008 |
||||||
|
|