At 03:59 PM 3/1/03 -0800, Alexander Luis Perez wrote: >I want to have a light seeking robot use phototransistors in a voltage >dividing circuit and >use the comparators on the 16f628 take the brightest of the two, but i >don't want to constantly adjust a potentiometer for all the varying light >levels. I once saw a project that did just that but didn't show any code >for it. could anyone help me with this? Use the comparitor in the '628. Here is one method: connect one side of both photo sensors to +5V. The other side of each sensor goes to pins RA1 & RA2. Also connected to pins RA1 & RA2 are pull-down resistors - you will need to experiment to find the best value but start with 10K. Set CMCON to b'00000101'. To find the best value of resistor for the pull-downs, use a meter between one of the sensors inputs (RA1 or RA2) and GND. Pick the resistor so that in the brightest light you expect to encounter, the voltage is no greater than about 3.5V. Now see what the voltage is in the lowest light level you expect to encounter - it should be greater than about 0.2V. Depending upon what sensors you are using, the resistor could be as high as 1M or 2M or as low as 1K or 2K. You just have to experiment. Use that value for both resistors. Now just look at CMCON bit 7. As one sensor becomes brighter than the other and vice versa, the state of that bit will change. Hope this helps. dwayne -- Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (780) 489-3199 voice (780) 487-6397 fax Celebrating 19 years of Engineering Innovation (1984 - 2003) .-. .-. .-. .-. .-. .-. .-. .-. .-. .- `-' `-' `-' `-' `-' `-' `-' `-' `-' Do NOT send unsolicited commercial email to this email address. This message neither grants consent to receive unsolicited commercial email nor is intended to solicit commercial email. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body