arduino in place of a rotary switch

hello i want to use the arduino to control a digital device in place of a rotary switch,
this device runs on 3.3 volts .the rotary contains resistors that divide the voltage 3.3 in lets say 6 positions .
I have thought of using a 4051 and put the equivalent resistor value to each pin
is there a better way?Will this work?

you don't need any hardware . the arduino can handle it itself. you just need to use pwm

http://www.arduino.cc/en/Tutorial/PWM

https://www.youtube.com/watch?v=Y1QraI5i_XM

.

There is a very important rule here.

You do not say "a digital device" that "runs on 3.3 volts".

You specify exactly what that device is, post a link to its full description including any datasheet available and either that description contains a photo or you provide one.

lexibelle: I have thought of using a 4051 and put the equivalent resistor value to each pin - is there a better way? Will this work?

This relates to the "XY problem".

hello again thank you for your answers .

i looked in to the pwm idea, wich would require less components so i asked an electrician to measure the current draw at the specific point (my multimeter must have a burned fuse )and he didn’t get any readings.
So the current draw is verry small and the arduino could handle it .

now the rotary switch that i spoke about could be considered as a 10k pot with discrete positions
wich divides the voltages gradually from 3.3 volts to 0 volts

the device is an digital audio prossesing device and no audio goes through that pot I am trying to replace ,it is only a menu control interface

I have post a picture below for the (x-z)problem
i don’t have and can not get a schematic

I thought of using a voltage reducer with resistors as described here
http://www.cellbots.com/how-to/handling-3-3v-to-5v-logic-level-conversion/
to get the voltage at 3.3 volts and then control it from the arduino with pwm

could you tell me the right way to do it?

thank you for your time

anyone?

In that article they mention this is what they use now Logic Level Converter
but yes that will get you down to 3.3v or you could use a Pro Mini which can run on 3.3v

If using PWM doesn’t work and you need a true analog voltage
you will need some form of DAC (digital to analog converter)

sparkfun DAC

R2R ladder DAC

R2R tutorial

thank you. just tested it. It does not work ,pwm is recognised from the device as two deferent voltages switching, so I will look for another way.

PWM may work when you run it through a RC filter. A resistor between the Arduino output pin and the device input, and a capacitor from the device input to Gnd.

You also can feed a R2R ladder from Arduino output pins. Your 4051 idea should work as well, provided your wiring is okay.

DrDiettrich: PWM may work when you run it through a RC filter. A resistor between the Arduino output pin and the device input, and a capacitor from the device input to Gnd.

You also can feed a R2R ladder from Arduino output pins. Your 4051 idea should work as well, provided your wiring is okay.

The RC filter will only work if you have an idea about the general resistance of the device. If the resistor chosen for the RC filter has the same as the device, the voltage will be cut in half. Also you need to calculate the RC by the frequency of the arduino PWM or it will give out false readings. Take a look at: DAC with a RC filter It even states the values for an arduino RC filter.

An RC filter might be tough to figure out correctly. Since your rotary switch is really just a R2R ladder anyway That would probably be easiest. the 4051 just would reduce the number of pins needed

I made a 5 bit r2r with 22k and 10k resistors and it worked ! :smiley: thank you all very much!

There are two types of rotary switches. One that makes the new connection before it opens the old connection. And one that opens the old connection before making the new connection. which type are you trying to emulate?

Paul