'--------Title-------- ' File......bounce2.pbp ' Started....6/1/05 ' Microcontroller used: Microchip Technology 16F88 ' 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. '--------Revision History-------- ' 11/6/07: Change MCU from 16F84A to 16F88 '---------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 OSCCON = $60 ' Sets the internal oscillator in the ' 16F88 to 4 MHz '-----Pin List for 18 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 PORTA.0 ' 9 PORTA.1 ' 10 PORTA.2 ' 11 PORTA.3 ' 12 PORTA.4 ' 13 PORTA.5 ' 14 PORTA.6 ' 15 PORTA.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