'--------Title-------- ' File......LCD2.pbp ' Started....3/18/06 ' Microcontroller used: Microchip Technology PIC16F88 ' microchip.com ' PicBasic Pro Code: micro-Engineering Labs, Inc. ' melabs.com '--------Program Desciption-------- ' Demonstrates several commands to move LCD cursor ' on a 16 x 2 LCD diaplay. '----------Related Lessons--------- ' See LCD BASICS lesson at: ' http://cornerstonerobotics.org/curriculum/lessons_year2/erii14_lcd1.pdf ' ' lcd2.pbp is used in the lesson LCD Command Control Codes at: ' http://cornerstonerobotics.org/curriculum/lessons_year2/erii15_lcd2_lcd_command_control_codes.pdf '-----------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) ' See schematic for the usual connections '---------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) '--------Revision History-------- ' 11/28/07 Add 16F88 oscillator and ANSEL = 0 ' initializations '---------Constants/Defines------- '---------Variables--------- c0 var byte ' Byte for counter c1 var byte ' Byte for second counter '---------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-------- pause 1000 ' Pause to allow LCD to setup start: lcdout $FE,1,"Three" ' Clears LCD screen, displays "Three" pause 1000 ' Pause 1 second lcdout $fe,1 ' Clears LCD sreen lcdout $FE,$C0,"days" ' Cursor moves to beginning of ' second line, displays "days" Pause 1000 ' Pause 1 second lcdout $fe,$14,"only" ' Cursor moves to right one ' position and displays "only" pause 1000 ' Pause 1 second lcdout $fe,1 ' Clears LCD sreen LCDout $fe,1,"Valid" ' Clear LCD screen, display "Valid" pause 1000 ' Pause 1 second for c0 = 1 to 5 ' FOR..NEXT loop so "Valid" scrolls ' off the screen to the left lcdout $fe,24 ' Scrolls display one character ' position to the left pause 100 ' Pause 100 milliseconds next ' Continue to next c0 LCDout $fe,1,"in store only"' Clear LCD screen, display "in store only" pause 1000 ' Pause 1 second for c0 = 1 to 16 ' FOR..NEXT loop so "in store only" ' scrolls off the screen to the right lcdout $fe,28 ' Scrolls display one character ' position to the right pause 100 ' Pause 100 milliseconds next ' Continue to next c0 for c1 = 1 to 2 ' FOR..NEXT loop to display ' CD's $5.00 two times LCDout $fe,1 ' Clear LCD screen LCDOUT $fe, $80+17,"CD's $5.00" ' Display "CD's $5.00" starting ' 17 positions from the beginning ' of the first line, i.e., just off ' LCD screen pause 200 ' Pause 1 second for c0 = 1 to 28 ' FOR..NEXT loop so "CD's $5.00" ' scrolls off the screen to the left lcdout $fe,24 ' Scrolls display one character ' position to the left pause 150 ' Pause 150 milliseconds next c0 ' Continue to next c0 next c1 ' Continue to next c1 Pause 500 ' Pause 500 milliseconds goto start ' Go to start label end