In France I can not find a 20K digipot for less than $15 delivered, so I would like to know whether I could replicate the effect of a digipot with simple transistors and resitors. I need a simple 4 step digipot: 0 ohm, 5K ohm, 10K ohm and 20K ohm, controlled by the arduino pins. I just don't know where to get started...
Start from reading data sheets for ANALOG MULTIPLEXER/DEMULTIPLEXER, M74HC4051
or similar. If you connect one resistor (20k) to common input/output, and 4 resistor ( 0, 5, 10, 20 ) to other inputs/outputs you 'd create a digitally controllable voltage divider. Varying value of resistors can get logarithmic/linear scale.
I can't get my head around what you're recommending: If you connect one resistor (20k) to common input/output, and 4 resistor ( 0, 5, 10, 20 ) to other inputs/outputs you 'd create a digitally controllable voltage divider
could you please be more specific?
Gadget999: salvaging a component from a printer? I would not recognize a digital pot if it were starring at me in the eye !!! So no - not a chance I open a printer for spares
O'k. Switches are 1 multiplexer IC chip. There are two A, and B shown, but millions possible variation could be created depends on requirement: linearity, accuracy, speed, quantity of steps etc. (Google to read on topic, search pattern "DAC resistors network").
For you, probably A is sufficient.
Terryking: That's pure genius!!! Thank you so much. I don't need any response speed at all - this is to control an already slow motor to make it even slower - set once and forget. So your solution is super.
Magician - thanks for the sketch - now it's all clear. I'll go the Terryking route though as it saves quite a few pins.
Put filter cap across the photoconductor if the ripple is too much. Sketch to calibrate it..
OK - I now had the chance to test this. I'm running into a bug: the PWM, too fast for the eye to see, keeps turning the LED on and off. The photoresistor on the other hand sees mostly "0", particularly at low brightness levels. Maybe 75%+ of values are 0. I use the analogWrite and analogRead functions.
int led=11;
int sensorPin = A0;
int pause=100;
int sensorValue = 0; // the sensor value
void setup()
{
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop()
{
for (int brightness = 0; brightness < 130; brightness++)
{
analogWrite(led, brightness);
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue,DEC);
delay(pause);
}
for (int brightness = 130; brightness >= 0; brightness--) {
analogWrite(led, brightness);
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue,DEC);
delay(pause);
}
}
So I don't think this is quite usable quite so easily.Or I missed something...