By the way I just tried adcon1=0 it didnt work again...How can I use porta.5 as analog input ????
By the way I just tried adcon1=0 it didnt work again...How can I use porta.5 as analog input ????
Knowing your PIC model would help us.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
ı wrote this code.
What i see on lcd is the values getting bigger .Started 90,100,108,120,145
How can i use first analog five input pins in 16f877a...
which setting is wrong ???DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 5
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE OSC 4
DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 100
SYMBOL VERI=PORTA.5
deneme var byte
ADCON1=10000010
TRISA=%11111111
basla:
LCDOUT $FE,1
adcin veri,deneme
LCDOUT $fe,2,#deneme," "
pause 3000
goto basla
end
1. you have to set trisa.5 to 1, make this pin as input
2. choose an ADCON1 setting that set AN4 as analog, =0 or =2 have to work
3. make sure analog comparator is disable. CMCON=7
4. use ADCIN with analog channel number, not his pin name
ADCIN 4, YourVariable
HTH
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I wrote this but same problem continues.the value starts 111 gets bigger and bigger up to about 249-254
Code:DEFINE LCD_DREG PORTB DEFINE LCD_DBIT 0 DEFINE LCD_RSREG PORTB DEFINE LCD_RSBIT 4 DEFINE LCD_EREG PORTB DEFINE LCD_EBIT 5 DEFINE LCD_BITS 4 DEFINE LCD_LINES 2 DEFINE OSC 4 DEFINE ADC_BITS 8 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 100 deneme var byte ADCON1=2 trisa.4=1 CMCON=7 basla: LCDOUT $FE,1 adcin 4,deneme LCDOUT $fe,2,#deneme," " pause 3000 goto basla
try ADCON1=%11100010
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
i tried this it worked !
deneme var byte
ADCON1=0
trisa.5=1
CMCON=7
basla:
LCDOUT $FE,1
adcin 4,deneme
LCDOUT $fe,2,#deneme," "
pause 3000
goto basla
after that i tried this it didnt work
values is getting smaller now..
its so weird
bilgi var byte
red var byte
green var byte
blue var byte
ADCON1=0
trisa.5=1
trisa.1=1
trisa.2=1
trisa.3=1
trisa.0=1
CMCON=7
TRISB=0
PORTB=0
TRISC=0
TRISD=0
LCDOUT $FE,1
yap:
high PORTD.7
PAUSE 750
ADCIN 5,bilgi
red=bilgi
pause 5
low PORTD.7
high PORTD.6
PAUSE 750
ADCIN 5,bilgi
blue=bilgi
pause 5
low PORTD.6
high PORTD.5
PAUSE 750
ADCIN 5,bilgi
green=bilgi
pause 5
low PORTD.5
CALL GOSTER
pause 7000
goto yap
GOSTER:
LCDOUT $fe,2,#red," ",#blue," ",#green," "
Where am i wrong this final code???
Bookmarks