
Originally Posted by
inventor2008
hi
I recently moved from my bs2 to pic's and I have a pic16f877A that I only recently got to work, and I've already gotten it to do most of basic stuff, blink and LED, run an LCD, run a servo, and so on... and today I started messing with the ad converter and just loaded one of the demo adc programs that came with pbp, to see what would happen and I got it to work, but It displays the digital value of portA.0 on the LCD and I was wondering would it be possible to display the value on portA.0 with LED's (say on portD) instead of the LCD so instead of seeing "Value : (and what ever number)" I would see 8 LED's displaying the binary value of portA.0.
Thanks

Originally Posted by
Skimask
trisd = 0 'set portd to all outputs
adresult var byte 'set up a byte that will receive the a/d input from the ADC
portd = adresult 'set portd to the result value
Hi inventor2008,
Skimask gave you nice tips. Since you're a beginner, i'll give you a working example of it.. just to compensate some "unwanted post" in your thread.
Code:
<font color="#000000"> <font color="#008000">'
' this assume you use a 20MHz crystal
' &
' PM as assembler
'
</font>@ device hs_osc, lvp_off
<font color="#000080">DEFINE </font>OSC 20
TRISA = 255 <font color="#008000">' PORTA = INPUT
</font>TRISD = 0 <font color="#008000">' PORTD = OUTPUT
</font><font color="#000080">DEFINE </font>ADC_BITS 8 <font color="#008000">' ADCIN resolution (Bits)
</font><font color="#000080">DEFINE </font>ADC_CLOCK 3 <font color="#008000">' ADC clock source (Frc)
</font><font color="#000080">DEFINE </font>ADC_SAMPLEUS 50 <font color="#008000">' ADC sampling time (uSec)
</font>ADResult <font color="#000080">VAR BYTE
</font>PORTD=0 <font color="#008000">' Clear all LEDs on PORTD
</font>Start:
<font color="#000080">ADCIN </font>0,ADResult
PORTD = ADResult
<font color="#000080">GOTO </font>Start
HTH
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks