Finished Pieces

Interfacing with the Arduino


    Here are 3 ways of interfacing the Arduino with various electronics, especially bent circuits and analog audio circuits. The circuits are actually pretty non-specific and can be used for interfacing with pretty much any micro controller, but we’ll just talk about the Arduino to keep it simple.
    The circuits above allow the Arduino to control physical electronics in three ways:
    -digitally controlled variable resistor
    -digital switch
    -variable voltage (using a digital to analog convertor).
    I’ll talk about each one in detail below.


    VARIABLE RESISTOR

    A simple, brute force way of using one of the PWM (pulse width modulation) outputs of the Arduino to create variable effects in other circuits.

    HOW IT WORKS:

    This simple circuit uses PWM to modulate the brightness of an LED. The LED is mechanically connected to an LDR which is a light sensitive resistor. As the brightness of the LED modulates, the resistance of the LDR changes as well. Read at the bottom of the page for more info on PWM.

    HOW TO BUILD:

    Making a vactrol
    For this circuit you first need to make a vactrol. There’s lots of tutorials for how to do this online if you want more info.
    -Connect an LED to a light dependent resistor face to face. I found that high brightness LEDs are TOO bright. Average red LEDs will work fine. You’ll also need a 220 ohm current limiting resistor in there to keep the LED from getting too bright and burning out.
    -The LED is polarized and the LDR is NOT. Mark the negative leg of the LED with a marker or piece of tape.
    -Make sure the face of the LED and the LDR are touching and wrap a piece of electrical tape or heat shrink tubing around them, something that will ensure that no light gets in.
    *If you want to be organized about it you can bend all of the legs in the same direction and solder them to a piece of perf board. This is a good way to do it if you want to make several vactrols for one system. Make sure the material you use to connect and insulate the LED/LDR is secure and wont let ANY light in.

    Now you can connect the vactrol to your system.
    Connecting the vactrol to the Arduino.
    -Connect the negative leg of the LED to the ground terminal of the Arduino.
    -Connect the positive leg of the LED to one of the PWM output pins of the Arduino.
    -Assigning a number value to the chosen output terminal will set the pulse width of a square wave at that terminal.

    Connecting the vactrol to your circuit.
    First you have to find a feature that you want to alter and CAN be alter by varying a resistance in your circuit. A good example of this is pitch. Most audio circuits have a pitch resistor. Altering the value of this resistor changes the pitch. For more info on this check out my pitch adjustment tutorial(If you follow that tutorial you will be using the vactrol in the “attenuator method”).
    -Find a resistor in your circuit that you want to control with the vactrol.
    -Remove that resistor. You may want to install a switch that lets you switch between vactrol control and a preset resistance.
    -Connect the two legs from the LDR in your vactrol to the two points on your board where the original resistor used to be.
    -Done.

    I strongly recommend installing a limiting resistor, especially if you are controlling pitch. Lowering the resistor too much can fry the circuit. a limiter resistor will guarantee that even if the LDR resistor drops to zero there will still be some resistance in the circuit.
    I’ve illustrated a few other configurations below which I have found useful in tuning in the Vactrol resistance range.

    A FEW NOTE ON LDRs

    • LDRs come in many different ranges of resistance. A common range is between 100 – 500k ohms. This range is from bright light to complete darkness.
    • Make sure the LDR in your vactrol is completely insulated from environmental light. ANY light that gets in, even in a dim room, can drastically alter the range of the LDR.
    • It is important that you use the LDR to replace a resistor of a similar value. For instance replacing a 1k resistor with a 500k LDR wont do much. It is possible to place a resistor in parallel with the LDR to tighten its range but this can drastically change its resistance curve.

    DIGITAL SWITCH


    DIGITAL TO ANALOG CONVERTOR

    This design is cheap and dirty but it works. It’s noisy and vulnerable to loading effects from low load resistance. There are lots of other schematics online which will give you more stable results. Most use op amps instead of transistors. I wanted something cheap and small so went with this design. It’s clean enough for what I’m doing and works fine if you are using it to drive an op amp input like the CV inputs of an analog synth.


    PWM – PULSE WIDTH MODULATION

    PWM is a way of creating a varying (analog) signal using a digital signal. Digital outs either generate 5 volts or 0 volts. That’s 2 states. If you want to generate a signal somewhere between those states you have to get clever. That’s where PWM comes in. The Arduino has several PWM output pins. These output a high frequency square wave with a variable duty cycle. Duty cycle is the ratio of time the wave is high vs low. Lets say 1 cycle of the wave is 100 micro seconds. A 50% duty cycle means the wave will be high for 50mS and low for 50mS. A 20% duty cycle will be high 80mS and low 20mS.

    Sounds

    Sorry, no sound files for this piece.

    5 Responses to “Interfacing with the Arduino”

    • 1

      valkiri said:
      February 7th, 2013 at 11:26am #

      Hi,

      Could you explain the digital switch section please?
      I would like to use the Arduino to trigger a sound from a toy, like if I push one of its button. Do you think I’m in the right place?

      Thanks 🙂

    • 2

      casper said:
      February 23rd, 2013 at 3:47pm #

      @Valkiri. Transistors are very useful and powerful little devices. Essentially they let you control the current flowing from one place to another by using a third and unrelated current source. For instance a pulse of current from the arduino can be used to allow current to flow between two points in a separate toy circuit. Its hard to go into much detail in a short answer. I suggest you look up transistor switching. its one of the most basic applications of the transistor and is easy to get working with very few parts.

    • 3

      valkiri said:
      February 27th, 2013 at 9:34am #

      Ok, thanks a lot for the answer. I’ve done it with a relay for a first test, and that’s already exciting 🙂
      I’ll try it with transistors and tell you about it. This with the vactrol, it will be very funny I think 😀

    • 4

      Chase Golematis said:
      January 18th, 2014 at 12:10pm #

      First and foremost I feel the extreme need to commend you on being so generous with your information, i’ve contacted people about this in the past they’ve all treated me like I was an idiot. I want to build a voice changer out of and Adruino and was wanting to use it in real time I wanted to lower the pitch of my own voice and be able to talk to people as I was doing my performance art what would be the best shield to use for this and do you have anything that you’ve ever done in the past like this. Also what I need to write code in order for it to work or can I just run a direct in some weird way, i’m under the impression that you do build some things for people is it also anything that could be commissioned to be built, though I openly admit I feel like this would be awesome for me to do as a project and would love the experience, the shield I like is the dj shield from nootropic.com and my adruino is a uno thank you

    • 5

      Chase Golematis said:
      January 18th, 2014 at 12:14pm #

      I mean the shield I wanted to use is the dj sorry for the long comment

    Leave a Reply

    If you're not already logged in, there might be a question you need to answer before you post to prove you're human. It's there to help stop comment spam.