# control by resistance

Hey guys,

I have a small camera which has day and night mode. Sadly it's not automatic. To switch from one mode to another you need to change the resistance on one of the camera pins. 2.2K is day and 10K is the night mode.

It's very easy to control it using small buttons and two resitors, but I would like to make it switch automatically. I already have a sketch and hardware which senses is it dark in the room - that works fine.

But how to make the arduino to change the reistance? Is using a digital pot the only way or maybe someone has an idea how to use just resistors as all i need are just two states (2.2K and 10K).

All the help really appreciated...

Presumably that is connecting pin to resistor to Gnd? Couple of logic level N-channel MOSFETs. Camera to resistor to drain, source to Gnd. Gate controlled by arduino.

It's not actually resistance controlled. It's probably voltage. Can you measure the voltage on that pin when each of the two resistors is applied? Then try to duplicate that voltage.

While analogWrite() might seem like the obvious solution, the best way is to use a digital output and a few resistors to create the required voltages. Three resistors should be able to do it, maybe more if you need an odd value in between the standard values. One to ground, one to 5V and one to your Arduino's digital pin. Calculate the resistor values for the two voltages when the pin is high and low.

I hope for your sake that the necessary voltage is less than your Arduino's maximum, otherwise you will need extra components like MOSFETs.

It's not actually resistance controlled. It's probably voltage

Probably an internal current source across external resistor that creates a voltage that a decision is made on.

CrossRoads: Presumably that is connecting pin to resistor to Gnd?

Yes

CrossRoads: Couple of logic level N-channel MOSFETs. Camera to resistor to drain, source to Gnd. Gate controlled by arduino.

I get that idea. That's actually quite easy. Thanks!

MorganS: It's not actually resistance controlled. It's probably voltage. Can you measure the voltage on that pin when each of the two resistors is applied? Then try to duplicate that voltage.

While analogWrite() might seem like the obvious solution, the best way is to use a digital output and a few resistors to create the required voltages. Three resistors should be able to do it, maybe more if you need an odd value in between the standard values. One to ground, one to 5V and one to your Arduino's digital pin. Calculate the resistor values for the two voltages when the pin is high and low.

I hope for your sake that the necessary voltage is less than your Arduino's maximum, otherwise you will need extra components like MOSFETs.

I'm sure it's only resistance as now i'm switching the day/night modes by simple 2 position mechanical switch which has both resistors connected to cameras gnd only.

Conceptually, a small reed relay would be the exact replacement. A latching one would require less power.

Reed relays:
http://www.digikey.com/product-search/en?pv668=9&FV=fff40010%2Cfff80368&k=reed+relay&mnonly=0&newproducts=0&ColumnSort=0&page=1&stock=1&quantity=0&ptm=0&fid=0&pageSize=25
4-5mA and up, \$1.10 and up.
Relatively slow too:
Operate Time 0.5ms
Release Time 0.2ms

Logic Level N-channel
MOSFET: uAs, \$0.44 & up. Also much smaller.
http://www.digikey.com/product-search/en?FV=fff40015%2Cfff8007d%2C1140050%2Cefc0005&k=n-channel+mosfet&mnonly=0&newproducts=0&ColumnSort=1000011&page=1&stock=1&pbfree=0&rohs=0&quantity=&ptm=0&fid=0&pageSize=25

AOI-514: < .012 ohm resistance at Vgs = 4.5V. 50 cents.
Turn-on, turn-off times measured in nanoSeconds. (probably not critical in this application)

I would suggest MOSFET is the better choice here.

One FET to bypass one of two resistors in series would do it nicely, requiring only a single output from the Arduino. Or if you have a multimeter, we can try to work out if it's doable with a simple diode.

Unless it's really 3 settings: open, 2.2K, 10K. Day Mode & Night Mode would seem to imply just 2.

I'm guessing it's actually not one nor the other, but probably some sort of reference for the the camera AGC. I'd be tempted to experiment and see if I could get proper gain control.

Leave the 10k in situ and switch 2k82 in parallel, thats 2k in series with 820R.

I need to get more N-mosfets as I have only one, but i’ve already have checked that CrossRoads idea works.

By accident I’ve noticed something else. When a digital pin is set to LOW - it’s state is basicly GND (checked with a multimeter).

So I’ve just added a resistor into the digital port and checked the resistance between that port and the boards GND - it shows the value of a resistor.

Why not just use two outputs with diferent resistors?

I mean like that:

digitalWrite(pin22k, LOW);
digitalWrite(pin10k, HIGH);

??
Edit:

Okay, I took the risk and tried. The upper version did not work…
However:
It works if one pin is set as output with a LOW state, and the second one is set to input.

I just need to switch between those two
//nightmode:
pinMode(pin22k, INPUT);
digitalWrite(pin10k, LOW);

or
//daymode:
pinMode(pin10k, INPUT);
digitalWrite(pin22k, LOW);

It works, but am I killing the board or something?

You don’t have to take the 10k out of the circuit, just put 2.8k (2k in series with 820R) in parallel, the result will be 2k2. Then you only have to switch one wire.

``````//nightmode:
pinMode(pin28k, INPUT);

or

//daymode:
pinMode(pin28k, OUTPUT);
digitalWrite(pin28k, LOW);
``````

klubfingers: You don't have to take the 10k out of the circuit, just put 2.8k (2k in series with 820R) in parallel, the result will be 2k2. Then you only have to switch one wire.

I understand the idea but I don't understand how to connect that. What's a 820R ? Also sorry but I don't understand what an 2k2 is. I'm just an amateur, but would love to understand that idea.

820R Is a 820 ohm resistor

2K2 Is a 2200 ohm resistor

Sorry 'bout that, Pixxel, I ass-oomed you knew.

Its shorthand, instead of 2.2k ohms I replace the decimal point with the k, saves a whole keystroke, instead of 3.3 volts, I write 3V3. If resistance is less than 1k I use R (for resistance) for Ohms since there is no “Ώ” symbol on the keyboard. OK?