nuno12345
Joined: 16 Jul 2008 Posts: 50
|
16F88 and ADC |
Posted: Thu Aug 07, 2008 6:14 pm |
|
|
Hi again, im trying to use the ADC of 16F88...
If I connect (completly turn my POT) to the "positive side" it reads well...
But if I decrease the POT strange characters start apearing :/
CODE:
Code: | #include <16F88.h>
#device adc=10
#fuses INTRC_IO, NOWDT, NOBROWNOUT, PUT, NOMCLR
#use delay(clock=4000000)
#include "flex_lcd.c"
long int q;
float p;
void main()
{
setup_adc( ADC_CLOCK_DIV_64 );
setup_adc_ports(sAN0);
set_adc_channel( 0 ); // AN0
lcd_init();
while(1)
{
q = read_adc();
p = 5.0 * q / 1024.0;
printf(lcd_putc, "\fADC = %4ld\nVoltage = %01.2fV", q, p);
delay_ms(200);
}
} |
Connections:
#define LCD_DB4 PIN_B4
#define LCD_DB5 PIN_B5
#define LCD_DB6 PIN_B6
#define LCD_DB7 PIN_B7
#define LCD_RS PIN_B1
#define LCD_RW PIN_B2
#define LCD_E PIN_B3
//#define USE_LCD_RW 1
CCS Version: 4.074
JDM Programmer |
|