Continue to Site

How to interface LEDs with a pot using 16F877 A/D converter?

Status
Not open for further replies.

xjackal

Full Member level 3
Full Member level 3
Joined
Jan 21, 2004
Messages
163
Helped
20
Reputation
40
Reaction score
8
Trophy points
1,298
Activity points
1,303
a/d c 877 help with asm

hi guys,
i need to interface a pair of leds(exactly 8) of them with a pot(linear) probabaly using 16f877 a/d cconverter.any help would be apppreciated.
:the problem is that i cannot see the leds starting from rb0 to rb7 but in random order.
and can u explain how the process works.
 

Re: a/d c 877 help with asm

Based on the little information you give, I'm guessing you make A/D readings and output them om PORTB?

In that case you get binary numbers represented on the LEDs, which might look a bit random if you don't know what your looking at.

Did you want some kind of bar graph or what?
 

Re: a/d c 877 help with asm

yea,
thanks for ur reply.
its just what i need to do.starting from rb0 to rb7.like bargraph...
but how to do it..
many thanks
 

Re: a/d c 877 help with asm

This is untested code, but I think it might work.

I'm assuming you have the AD result in a memory location called "res" and have another location named "tmp".

Code:
swapf res,w
andlw 0x0f
movwf res
rrf res,f ; res is now divided by 32, so is in the range 0-7
incf res,f

clrf tmp

loop:
bsf STATUS,C
rlf tmp,f
decfsz res
goto loop

movf tmp,w
movwf PORTB
 

Re: a/d c 877 help with asm

how about using a bargarph.how to use it.
because i cannot seemto work my codes properly.
 

a/d c 877 help with asm

Hi,

First of all, configure your ADC into an 8bit or 10bit ADC.

Second, in using an 8 position bar graph, you must divide your maximum level readout equivalent by 8.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top