Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 25th March 2005, 12:38 PM   #1
Default LDR 16F877

I have Pbp. I use 16F877. I want to use analog ports A and E. get output from B channels. (for example channel 0). I know how to connect the channels and other circuit elements. All I want to learn is how can I get the 0 and 1 from analog channels. As far as I understand A/D conversion gives too much bits, I only want to take 0 and 1. For example when the LDR voltage is above 3 I want to light the led when it is below turn off the led. i think the program is so simple, please send me one, i need this for my term project
ser_kant is offline  
Old 25th March 2005, 01:23 PM   #2
Default Re: LDR 16F877

Quote:
Originally Posted by ser_kant
I have Pbp. I use 16F877. I want to use analog ports A and E. get output from B channels. (for example channel 0). I know how to connect the channels and other circuit elements. All I want to learn is how can I get the 0 and 1 from analog channels. As far as I understand A/D conversion gives too much bits, I only want to take 0 and 1. For example when the LDR voltage is above 3 I want to light the led when it is below turn off the led. i think the program is so simple, please send me one, i need this for my term project
You read the analogue value from the LDR into a register, you may as well only use the top 8 bits, rather than the full 10 bits (it will simplify things).

You then test the value, it could look something like this:

Code:
If Reading > Testvalue Then
  Do Over
Else
  Do Under
To do it in assembler you subtract the values, and test the status flags, if you check on the PICList there is a complete section about such comparisons.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply

Tags
ldr

Thread Tools
Display Modes




All times are GMT. The time now is 03:50 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker