'--------Title-------- ' File......shift1.pbp ' Started....5/21/08 ' Microcontroller used: Microchip Technology PIC16F88 ' microchip.com ' PicBasic Pro Code: micro-Engineering Labs, Inc. ' melabs.com '--------Program Desciption-------- ' Program uses the shift left operator, <<, to shift ' variable to the left 1 time (same as multiply by 2). ' Both decimal and binary values are displayed on an LCD. '----------PIC Connections--------- ' 16F88 Pin Wiring ' --------- ---------- ' RA0 LCD pin 11(DB4) ' RA1 LCD pin 12(DB5) ' RA2 LCD pin 13(DB6) ' RA3 LCD pin 14(DB7) ' RA4 LCD Register Select(RS) ' RB3 LCD Enable(E) ' Vdd +5 V ' Vss Ground ' MCLR 4.7K Resistor to +5 V '---------LCD Connections--------- ' LCD Pin Wiring ' --------- ---------- ' 1 Ground(Vss) ' 2 + 5v(Vdd) ' 3 Center of 20K Pot(Contrast) ' 4 RA4(Register Select,RS) ' 5 Ground(Read/Write,R/W) ' 6 RB3(Enable) ' 7 No Connection(DB0) ' 8 No Connection(DB1) ' 9 No Connection(DB2) ' 10 No Connection(DB3) ' 11 RA0(DB4) ' 12 RA1(DB5) ' 13 RA2(DB6) ' 14 RA3(DB7) '------------Variables------------ i var byte ' BYTE to store counter variable, i s0 var byte ' BYTE to store shift variable, s0 '----------Initialization--------- ANSEL = 0 ' Configure all pins to digital ' operation since not using ADC ' (Analog to Digital Converter) OSCCON = $60 ' Sets the internal oscillator in the ' 16F88 to 4 MHz '------------Main Code------------ loop: s0 = 3 ' Start out with s0 = 1 for i = 1 to 7 ' Cycle through FOR..NEXT loop 7 times lcdout $fe,1,"Decimal ",dec s0 ' Display decimal value of s0 on first ' line of LCD lcdout $fe,$C0,"Binary ","%",bin s0 ' Display binary value of s0 on second ' line of LCD pause 2000 ' Pause 2000 ms or 2 seconds s0 = (s0<<1) ' Shift left operator shifts value of ' s0 to left 1 time (same as multiply by 2). ' The new bits that are shifted in are set ' to 0. next i ' Go back to the FOR statement and do ' next count goto loop ' Loop forever end