James and Iliana Holbrook wrote: > > Hello, > As a beginner with PIC's I don't have the programming skills to implement > a function that I would like to use. I have worked with the BASIC STAMP 2 > and would like to make a function that is available on the BS2. It's called > the RCTIME command and what it does is read a resistive value by charging > up a capacitor and measuring how long it takes to discharge through an > unknown resistor. > My idea is to make a pin an output for a fixed length of time, change to > input and loop until it went low, count the loops and return with the value. > Does this sound crazy ?? Would I be wasting my time trying to debug some > code for this function ?? > Any ideas would be appreciated. I'm using a 16C84 with a 4 mhz osc. > My goal is to read a photoresistor. > Thanks !! Go for it - it works well. Here's a starting point : 5V --- | | / \ / Light Dependant Resistor \ / 220 Ohm | ----/\/\/\-----| | | --- --- Cap | | ----- --- - You can use the formula : Time = LDR*Cap. Don't leave out the current limiting resistor! -- Friendly Regards Tjaart van der Walt mailto:tjaart@wasp.co.za _____________________________________________________________ | Another sun-deprived R&D Engineer slaving away in a dungeon | | WASP International http://wasp.co.za | | GSM and GPS value-added applications | | Voice : +27-(0)11-622-8686 | Fax : +27-(0)11-622-8686 | |_____________________________________________________________|