0% found this document useful (0 votes)
21 views2 pages

C:/Documents and Settings/Dad/Desktop/Website 2007/staging/code/16F877A - Bounce1.pb

This document contains the code for a Microchip PIC microcontroller program that causes eight LEDs to scroll on and off from left to right, then from right to left. It includes information on the microcontroller used, the schematic, and revision history. The code uses FOR-NEXT loops and variables to turn each LED on for 250 milliseconds before turning it off and moving to the next LED in the sequence.

Uploaded by

MEOW41
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

C:/Documents and Settings/Dad/Desktop/Website 2007/staging/code/16F877A - Bounce1.pb

This document contains the code for a Microchip PIC microcontroller program that causes eight LEDs to scroll on and off from left to right, then from right to left. It includes information on the microcontroller used, the schematic, and revision history. The code uses FOR-NEXT loops and variables to turn each LED on for 250 milliseconds before turning it off and moving to the next LED in the sequence.

Uploaded by

MEOW41
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

C:\Documents and Settings\Dad\Desktop\Website 2007\staging\code\16F877A_bounce1.

pb

'---------------Title-------------'
'
'
'
'
'

File......16F877A_bounce1.pbp
Started....6/1/05
Microcontroller used: Microchip Technology 16F877A
microchip.com
PicBasic Pro Code, micro-Engineering Labs, Inc.
melabs.com

'--------Program Desciption-------' Eight LED's scroll on then off from left to right
' then from right to left.
'-------------Schematic-----------' See schematic at:
' http://www.cornerstonerobotics.org/schematics/pic16f877a_bounce.pdf
'---------Revision History--------' 11/6/07:
' 1/1/09:

Change MCU from 16F84A to 16F88


Change MCU from 16F88 to 16F877A

'------------Variables------------LED VAR BYTE

' Variable LED setup as a byte

'-----------Initialization--------PORTB = %00000000

' Sets all PORTB pins to LOW (turns off


' all LEDs)

TRISB = %00000000

' Sets up pins RB7-RB0 of PORTB as outputs

'-----Pin List for 40 Pin Microcontrollers----'

Pin

'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Page 1 of 2

PORT/Pin
PORTB.0
PORTB.1
PORTB.2
PORTB.3
PORTB.4
PORTB.5
PORTB.6
PORTB.7
PORTC.0
PORTC.1
PORTC.2
PORTC.3
PORTC.4
PORTC.5
PORTC.6
PORTC.7

1/10/2009 8:44 AM

C:\Documents and Settings\Dad\Desktop\Website 2007\staging\code\16F877A_bounce1.pb

'-------------Main Code-----------start:

' start label

' Loops LEDs to right:


FOR LED = 0 TO 7

' Loops through all 8 LEDs.


' Since STEP is not given, the
' increment is automatically +1.

HIGH LED

' Turns on LED one at a time

PAUSE 250

' Holds LED on for 250 milli-seconds

LOW LED

' Turns off LED

NEXT LED

' Goes to next LED

' Loops LEDs to left:


FOR LED = 6 TO 1 STEP
'
'
'
'

-1
Loop through 6 middle LEDs.
STEP is a negative number so
the variable LED will decrease by 1
each time through the FOR..NEXT loop.

HIGH LED

' Turns on LED one at a time

PAUSE 250

' Holds LED on for 250 milli-seconds

LOW LED

' Turns off LED

NEXT LED

' Goes to next LED

' Loop back to the beginning:


GOTO start

' Loops back to the start label

END

Page 2 of 2

1/10/2009 8:44 AM

You might also like