'---------------Title-------------- ' File......16F877A_bounce2.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 off then on from left to right ' then back from right to left. '-------------Schematic------------ ' See schematic at: ' http://www.cornerstonerobotics.org/schematics/pic16f877a_bounce.pdf '---------Revision History--------- ' 11/6/07: Change MCU from 16F84A to 16F88 ' 1/1/09: Change MCU from 16F88 to 16F877A '------------Variables------------- LED VAR BYTE ' Variable LED setup as a byte '----------Initialization---------- PORTB = %11111111 ' Sets all PORTB pins to HIGH (turns on ' all LEDs) TRISB = %00000000 ' Sets up pins RB7-RB0 of PORTB as outputs '-----Pin List for 40 Pin Microcontrollers----- ' Pin PORT/Pin ' 0 PORTB.0 ' 1 PORTB.1 ' 2 PORTB.2 ' 3 PORTB.3 ' 4 PORTB.4 ' 5 PORTB.5 ' 6 PORTB.6 ' 7 PORTB.7 ' 8 PORTC.0 ' 9 PORTC.1 ' 10 PORTC.2 ' 11 PORTC.3 ' 12 PORTC.4 ' 13 PORTC.5 ' 14 PORTC.6 ' 15 PORTC.7 '-------------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. LOW LED ' Turns off one LED at a time Pause 250 ' Holds LED on for 250 milli-seconds HIGH LED ' Turns LED back on 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. LOW LED ' Turns off one LED at a time Pause 250 ' Holds LED on for 250 milli-seconds HIGH LED ' Turns LED back on Next LED ' Goes to next LED ' Loop back to the beginning: GoTo start ' Loops back to the start label End