I'm trying to get a 16f88 to read a voltage and display it on a LCD.
I have been able to display code on an LCD before, and using a 12f683 I have output serial data to a PC. With this project I am trying to display the analog data directly onto a LCD screen.
The LCD is connected to the default connections on the 16f88, an LED connected to RB1, and a variable voltage to AN0.
The code compiles correctly without errors however when I hook everythign up I get no readout on the LCD and the LED does not flash.
I'm hoping it's just something simple as this is my first time using the pic16f88 although I've been using the 16f84, 16f627a, 16f683 and 16f675 for about a month.
If anyone has any pointers I've really appreciate hearing them.
Thanks
CODE:
'************************************************* ***************
'* Name : LCDTest2.pbp *
'* Author : Greensasquatch *
'* Notice : Copyright (c) 2008 greensasquatch.ca *
'* : All Rights Reserved *
'* Date : 05/09/2008 *
'* Chip : PIC16F88 *
'* Version : 1.0.1 *
'* Notes : Send a message to a LCD on default pins *
'* : read an analog value and outout on the LCD *
'************************************************* ***************
'* PicBasicPro program to demonstrate operation of an LCD *
'* in 4-bit mode. *
'* THIS VERSION: To function on a PIC16F88 and output the *
'* voltage on the second line of the LCD. *
'************************************************* ***************
INCLUDE "MODEDEFS.BAS"
@ DEVICE INTRC_OSC_NOCLKOUT, MCLR_OFF
DEFINE OSC 8 ' define ADCIN parameters
DEFINE ADC_BITS 10 ' set number of bits in result
DEFINE ADC_CLOCK 3 ' set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' set sampling time in uS
adval VAR WORD ' store adc value
redLED VAR PORTB.1 ' alias redLED with RB1
ADCON0.7 = 1 ' right justify result
ANSEL = %00000001 ' set AN0 analog, rest digital
CMCON = 7 ' analog comparators off
Output PORTB.1 ' set RB1 as output
Pause 1500 ' wait for LCD to startup
loop: Toggle redLED
ADCIN 0, adval ' read channel 0 to adval (0-1023)
adval = (adval */ 500)>>2 ' equal to (adval * 500)/1024
Lcdout $fe, 1 ' clear LCD screen
Lcdout "Greensasquatch"' display Greensasquatch on 1st line
' move cursor to 2nd line, display voltage
Lcdout $fe,$c0, "DC Volts= ", DEC (adval/100), ".", DEC2 adval
Pause 1000 ' wait 1 second
Goto loop ' loop forever
Bookmarks