'--------Title-------- ' File......LCD3.pbp ' Started....3/23/06 ' Microcontroller used: Microchip Technology PIC16F88 ' microchip.com ' PicBasic Pro Code: micro-Engineering Labs, Inc. ' melabs.com '--------Program Desciption-------- ' Display resistance readings from a potentiometer ' on parallel LCD display. '----------Related Lessons--------- ' See LCD BASICS lesson at: ' http://cornerstonerobotics.org/curriculum/lessons_year2/erii14_lcd1.pdf ' ' lcd3.pbp is used in the lesson LCD POT COMMAND AND LCD DEFINES at: ' http://www.cornerstonerobotics.org/curriculum/lessons_year2/erii16_lcd3_pot_command_and_lcd_defines.pdf '------------Comments-------------- ' Other resistive components(5k to 50K) may be substituted ' for the potentiometer such as, ceramic photo ' resistor or resistive flex sensor. ' See PIC Microcontroller Project Book by John Iovine, ' pages 189 and following for a discussion on reading ' resistive sensors. '-----New PicBasic Pro Commands---- ' The PicBasic Pro Compiler Manual is on line at: ' http://www.microengineeringlabs.com/resources/index.htm#Manuals ' ' POT Pin, Scale, Var ' POT reads a potentiometer or other resistive components ' (5K-50K) from a specified Pin. ' Adjust Scale for the varying RC constants. ' Look around page 118 in the PicBasic Pro Compiler Manual '------------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) ' RB1 Resistive Input ' 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 Change MCU from 16F84A to 16F88 ' 11/28/07 Add 16F88 oscillator and ANSEL = 0 ' initializations '---------Variables--------- p0 var byte ' Byte for potentiometer reading '---------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 ' 1 second pause to allow LCD to setup start: ' Start label for loop pot 1,255,p0 ' POT command, potentiometer reading ' sent to RB1, scale set for 255, p0 ' assigned reading of potentiometer. ' p0 value may vary from a ' minimum of 0 to a maximum of 255. ' In order to obtain the maximum reading ' of 255, you will probably have to ' experiment with the value of the capacitor. lcdout $FE,1,"Pot Reading", $14, #p0 ' Clears LCD screen, displays "Pot Reading" ' Cursor moves to right one position and ' displays value of p0 pause 100 ' Pause 1/10 second goto start ' Loop to start label end