Introduction: Building the Blinquencer- a Light Controlled Random Music Box
This Instructable will show you how to build a Blinquencer- a semi-random optical melody generator that uses three blinking LEDs shining on a pair of light dependent resistors to control the pitch of two simple audio circuits to create melodic and rhythmic patterns. If that sounds technical don't worry, it's a really simple project that gives impressive results and it's a great introduction to noise circuits and generative music. It also makes a cool nightlight. Check out the video and see what it does and how it sounds and read on to see how to build your own.
Aside from a couple of ICs, a few LEDs and a fresh protoboard (less than $1 worth of stuff), I used all recycled and repurposed parts and materials for this project. It is designed to run from batteries for portability or a recycled wall wart for use around the house. While you could build a similar device from all new parts, I wish to demonstrate that money doesn't have to be a factor in electronics exploration and creation- save your money for better tools!
When I got into noise circuits, one of the first interfaces I learned was using a light dependent resistor to control the pitch of an oscillator. Basically, an LDR acts like a light controlled potentiometer- the brighter the light falling on the sensor, the lower the resistance. The darker it is, the higher the resistance. Total darkness blocks practically all current, acting like a switch. By using a LDR for the resistor in a typical R/C inverter oscillator, you can control the rate or pitch of that circuit with light.
I began to experiment with various light sources such as TVs and monitors, Christmas lights, strobes, flashlights and anything else that blinked, glowed or lit up. I eventually saw the Bleep Labs' Thingamagoop with its blinking LED on a flexible wire stalk that used a photosensor to affect the sound produced. This inspired a lot of my own projects like the one featured here. By having the LED on the end of a semi-rigid wire, you could use distance and position of the light source to control the amount of light falling on the sensor. If you have multiple stalks with LEDs you can switch them on and off and get different notes from a sound circuit with an LDR.
This project uses a CD40106 chip. This is a basic CMOS logic gate which is one of the building blocks of modern computers and digital devices. This is a digital circuit. Digital circuits read and create signals which turn off and on at controlled times. This creates a series of 'on' and 'off' signals, which can represent a binary code. While CMOS logic gates are primarily used for computations and data routing, they can be used to create sounds*. This circuit uses oscillators, circuits which turn off and on at an even, controllable pace. At slower rates these circuits are called clocks and can be used to measure divisions of time. If you listened to the signal created by a low speed oscillator it would sound like a steady stream of even clicks. If we sped this oscillator up the clicks would get closer and closer together until it created a steady buzz, like a snare drum roll. If you continued to speed the signal up it would begin to sound like notes- the faster the oscillator, the higher the note. By carefully controlling the speed of the oscillator we can get specific notes and even melodies.
The CD40106 consists of six inverters. An inverter has an input and an output. If you put an 'on' signal (called a '1' in binary language) into the inverters input, it will give the opposite output- in this case an 'off' (or '0'). In very simple terms, our circuit detects a 0 (power off) on its input pin and gives a 1 (power on) on its output pin. This 1 (power on) goes through a simple resistor/capacitor combo that builds up a charge and then releases it back to the inverter's input. This is read as a 1, or 'on' signal, causing the inverter to change its output to 0 or 'off'. This causes the R/C circuit to drain and stop discharging to the input pin, causing it to read as 0 again. This happens over and over again. The values of the resistor and capacitor used will control the speed at which the oscillator cycles back and forth between on and off, 1 and 0. This even on/off signal is called a square wave and is the basis for many synthesizer and sound circuits as well as many non-audio circuits.
Since the CD40106 has six separate inverters we can use it to make six independent oscillators that cycle at different rates. We will use three inverters with potentiometers to control the rate of three blinking LEDs. These LEDs shine onto two light sensitive resistors which control the pitch of two audio oscillators built from two more of the inverters. The final inverter is used to build an LFO or low frequency oscillator that turns the output of the two audio oscillators on and off quickly for tremolo and rhythmic effects at a rate controlled by a potentiometer. By carefully adjusting the pitch of the audio oscillators, the speed of the three blinking LEDs and the rate of the LFO, interesting musical and tonal patterns evolve and change over time.
Sound fun? Here we go...
* A note on CMOS sounds-
For a look at what CMOS logic chips can do check out this short clip of my Lunetta synthesizer. Lunetta's, named for creator Stanley Lunetta, use CMOS logic chips and an open patchable system of connections to create tones, patterns, control voltages and raw, amazing sounds. Lunettas are the opposite of traditional synthesizers- while a Moog is used to create sounds, a Lunetta is used to discover them. There's an amazing community of enthusiasts over at electro-music.com who are more than happy to introduce you to the wonderful world of digital noise and generative music.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Gather Your Materials
Here's a basic list of materials I used for my build. Feel free to modify or substitute these materials any way you want. I tend to be stubborn about recycling whatever I can, but you can use new parts and materials just as easily.
I'm using a Bobbi Brown cosmetics gift box made from heavy paste board that my wife brought home from work. My wife manages a beauty department in a high end retailer and always brings me cool boxes for my projects. Use whatever you have at hand or build something from scraps. Cigar boxes work nice.
Electrical components*- I use recycled components whenever possible, but you can get them wherever it's convenient.
6- 50k potentiometers
1- 10k potentiometer
2 spdt toggle switches
1- 1/4" audio jack
1- CD 40106 hex schmitt inverter
1- PC817 opto-isolator (or a DIY photo bridge with an LED nad a photoresistor sealed in a blacked-out tube)
2- light dependent resistors (photoresistors, photocells, CdS cells, etc.)
2- LED holders
6- 2.2k resistors
2- 56k resistors
1- 4.3k resistor
1- 330 ohm resistor
3- 100uf capacitors
2- .47uf capacitors
1 47uf capacitor
1- 10uf capacitor.
1- 9v battery
You will also want to gather the following tools and materials or their equivalents-
A few scrap pieces of Romex or similar stiff copper wire.
A small amplifier
Hand drill and bits
Heat shrink tubing
Various fasteners (old fashioned screw jar)
Get all your tools and supplies together on a clean, flat surface. When using solder and glue work on some kind of mat to keep the table or desk clean. Solder is hot! If you are new to soldering check out some of the tutorials found on the web and come back when you can solder- it shouldn't take very long at all. Solder in a well ventilated area. Be careful with hot, sharp, heavy, toxic or electrified things. Use your head. Plan your work and work your plan. If you screw up try again. Be careful and use common sense and don't blame me for any misfortune experienced while trying to emulate this project.
*A note on components-
When I first got into electronics I had limited resources. The online parts distributors had good prices but the jargon and variety made finding the parts I wanted very daunting. Radio Shack had a good basic selection of components, but their prices were high. I wanted a large selection of components in many different values in order to experiment freely. That's when I saw the ad that changed my life- Harbor Freight had a dual temperature heat gun on sale for $7.99. I had tried to salvage parts from old circuit boards with a soldering iron but it was time consuming and often resulted in damaged parts. I figured eight bucks was cheap enough to take a chance.
Sure enough I could strip a whole board in minutes with a putty knife and a heat gun. The heat was distributed in a wider area so the parts survived the process much better. I soon had piles of components and spent a few nights identifying and sorting them. They were put into small zip lock bags and stored in boxes. I built hundreds of circuits from parts recycled from the garbage!
I now buy parts in bulk from China and I keep a good supply on hand at all times but for these Instructables projects I want to use as much recycled materials as possible to show that money is not a stumbling block to creativity. Many of the parts I used for this project came from an old 16 channel mixer that I was given. Each channel had a separate board with capacitors, resistors, pots, push button switches, diodes and opamp chips. There were also knobs, 1/4" jacks, slide pots, wire and other components. There were over 120 pots in several values! That would cost close to $500 at Radio Shack, and that's not even counting the other parts.
Step 2: Let's Build the LED Stalks
The LEDs are mounted on the end of a piece of malleable copper wire so they can be moved to different heights and angles for different light/sound effects.
Cut three pieces of stiff , insulated copper wire about 12" long. I used recycled Romex house wire. Do the following for each stalk. Strip 1/4 inch from one end and 3/4" from the other end of the stiff wire. Solder the ground lead of the LED (the shorter one) to the 1/4" end. Be careful to heat the thick copper wire rather than the LED lead to avoid overheating it. Cover the joint with a short piece of heat shrink tubing. Solder a 20" piece of hookup wire to the positive lead of the LED (the longer lead). Cover this joint in a thin piece of heat shrink tubing also. Wrap the long positive lead evenly around the stiffer wire, spaced about 1/4-1/2" apart and secure the bottom with a piece of heat shrink tubing just above the end of the insulation. This should leave you with at least a few inches of positive lead and 3/4" of the bare copper negative lead sticking out of the bottom of the stalk. I then reinforced the LED with a few layers of tubing. I position the tubing to the end of the LED and shrink it carefully to create a 'spotlight' effect.
I usually wrap the stalks with something. With this glossy black box I decided to use black heat shrink tubing, but there are other options. Bleep Labs wraps their stalk with tightly wrapped wire. I've used the woven 'sleeve' from thin kern mantel style rope, sealing the ends with Heat shrink tubing. This adds color and looks neat and classy. In this case I cut an appropriately sized piece of tubing and tightened it up with a lighter, from the base of the LED to about 1" from the bottom.
Now your stalks are done. Put them aside until the final assembly.
Step 3: Preparing Your Box
With a simple project like this using panel mounted controls and recycled components, I find that it's easier to solder the components directly to the controls rather then mounting them on a circuit board. This is much easier when the pots, switches, jacks and other parts are mounted loosely in the enclosure before assembly of the circuit.
I traced the top panel of my box onto graph paper* and planned out where the various parts would go (see the above picture). Lay out your controls and connections however you like, but make sure there's enough room for knobs and that the controls are not too crowded. Will your fingers bump other controls when you turn a knob or flip a switch? Make sure your hands don't block the LEDs when you make adjustments. Will the cable connecting your amplifier get in the way? Are your light dependent resistors located in a way that they get the biggest variation in light from the LEDs?
Once you have determined a good layout, tape the graph paper guide to your box and use an awl or other pointed tool to mark your locations. Mount a small block of wood to the inside of the box under the holes for your LED stalks. Use screws from the top and an appropriate adhesive for the materials used. The block of wood serves to stabilize the stalks and provide a secure point to attach them. It should be large enough to cover each of the three stalk holes adequately and provide room for the stalk mounting screws. Carefully drill out each point to the appropriate size for its corresponding component. Go slow and use the right bit and drill speed for the material you are working with.
If you are going to paint or otherwise coat your enclosure do so now. When it is thoroughly dry loosely install the pots, switches, LDR holders and audio jack. Be careful not to mar your coating. As you install the parts mark the inside of the box with each component's function to make later assembly easier (vol, power, LED rate 1, LED rate 2, LED rate 3, Pitch 1, pitch 2, LFO on/off, LFO rate, LDR 1, LDR 2, LED1, LED 2, LED 3, out).
* A note on my paper-
If you look at my yellowed old rag graph paper with the blue lines and feel nostalgic, congratulations- you're old! This literally old-school graph paper was a classroom standard for years. My mom, a retired teacher, rescued a half a case of this classic old paper from the dumpster at her school and brought it to me. Nothing is wasted! This stuff makes me feel like I'm back in 6th grade drawing dungeon maps for our ongoing lunchtime D&D campaign. My circuits need more dragons!
Step 4: Building the LED Control Oscillators
Now we will build the three oscillator circuits that control how fast each LED blinks. Look at the drawing of the CD40106 above. This is a basic representation of what the pins do. Look at your chip. It should have a small indentation in one end. This is the top of the chip. The pins are numbered starting with the top left pin and going counter clockwise around the chip, ending with the top right corner. The 40106 has 14 pins. Each triangle on the drawing represents an inverter, for example, if pin 1 reads a '1', pin 2 will give a '0'. Pin 14 is a common power input and pin 7 is a common ground.
The first thing is to solder the 40106 to a circuit board with color coded leads about 6-8" long. Do this quickly as the 40106 is a little sensitive to excess heat and can be damaged if it's overheated. If you are new to circuit building use a 14 pin IC socket from Radio Shack. This allows you to solder a socket in place of the chip and plug it in later to avoid heat or static damage. Since I have a lot of wire* I used a different color for each pin on the left side of the chip and repeated it on the right side as follows-
pin 3- green
pin 4- yellow
pin 5- orange
pin 6- brown
pin 7- black
pin 8- brown
pin 9- orange
pin 10- yellow
pin 11- green
pin 12- blue
pin 13- purple
pin 14- red
This color code makes hooking up to the rest of the circuit less confusing.
Now look at the circuit drawings above. One is a basic schematic of the circuit and the other is a diagram of how I connected the circuit in my project. This circuit should be repeated for pins 1&2, 3&4 and 5&6. This is just an example- feel free to adapt the design however you see fit. I personally find this control-side circuit design a little quicker to work with on simple things like this and it makes it much easier to see how it hooks up. Solder this up and test it out. Connect the red and black leads to a bread board and connect a battery clip to the same rows. Connect the lead from the 100uf capacitor to the ground lead. Plug the LED lead from the pot to a free row on the breadboard and connect the positive lead from the LED stalk to the same row. Plug the battery into the clip and touch the thick negative lead from the LED stalk to ground. If the LED flashes and changes speed when you turn the pot congratulations- it works- if not recheck your connections, make sure there are no shorts or solder bridges, take a deep breath and keep trying until it works. It will eventually.
The astute maker will notice that the 2.2k resistor in series with the LED is a bit larger than is necessary. Usually an LED of this type will use a 330 ohm resistor at this voltage-+. In this circuit this made the LEDs a little too bright for our purposes. The higher value resistor dims the LED a little bit to give us a better range of notes with the light dependent resistor used to control the audio oscillators. Feel free to experiment with resistor and capacitor values to see what happens.
When you have soldered and tested all three oscillators go on to the next step.
*A note on wire-
Buying wire for hobby electronics is a sucker's bet. There is a ton of free wire out there for the taking. For heavy gauge wire try construction dumpsters or household remodeling sites. I use old telephone wire for all my circuits. A fellow trash picker brought me a 6 1/2' piece of old telephone transmission cable. I cut it open and found eight bundles of wire containing 50 individual strands each. There was over 2,400' of wire there in ten colors! Cat 5 data networking cable is also a good source of hookup wire. You can even get usable lengths of wire from old stereos and computers. Be creative and keep your eyes open- there's free supplies everywhere!
Step 5: Building the Audio Oscillators
Now we will build two audio oscillators using pins 13&12 and 11&10 of the 40106. Look at the circuit diagram and the schematic above. It looks quite a bit like the LED timer circuit we just built. The main difference is the value of the components used. While the first circuit used a 100uf capacitor, this circuit uses a .47uf cap. The first circuit also uses a 2.2k resistor in series with the 50k potentiometer while this circuit uses a light dependent resistor with the pot. These components comprise the R/C circuit that controls the rate of the oscillator*.
In the previous circuit we used a 2.2k resistor at R1. This limits the range of the timer oscillator a little bit. Without it, as we turned the pot up, the LED would start to blink too fast to be useful for our purpose. In this circuit we will replace the 2.2k resistor with a light dependent resistor. In this case the LDR detects the light level from the LEDs, creating a signal of varying speeds. Since we used a lower value capacitor at C2 our oscillator cycles much faster, creating an audible signal of varying frequencies, or 'music'. The potentiometer adjusts the overall range of notes played by acting as an adjustable limiting resistor.
You will also notice a higher value resistor at R3. Since we are using two audio oscillators we will use a 56k resistor on each output to attenuate, or reduce the power of, the signals. Without these resistors the two signals may be too strong and could cause distortion.
Wire this circuit like the diagram suggests and test it out. Breadboard it like the previous circuit, but wire the output through a 10uf capacitor. Solder two 5-6" leads to the 1/4" audio jack. Connect one side of the jack to the output of the cap and the other side to ground. Connect your amplifier and turn it on. Adjust the pot and move your hand in front of the LDR. If you get a controllable audio signal that gets higher in pitch when the light gets brighter and lower when it's in shadows, then your circuit is successful. If not then take your time and figure out why.
*A note on R/C circuits-
One way to look at electronics is to compare it to plumbing. Electricity flows through wires much the same way as water flows through a pipe. We use switches to stop the flow of electricity just like a valve stops the flow of water. For a circuit to work it needs to make a complete path from the positive post of the power supply to the ground. In our plumbing analogy, the positive side of the battery is like a reservoir and the ground is like the drain and sewage system.
The water that comes to your house travels from the reservoir in large pipes- sometimes several feet in diameter. These large pipes are split into several smaller pipes that branch off to supply different parts of your town. At each house an even smaller pipe is connected to bring water in. Finally, the water is directed through even smaller tubes to supply the sinks, toilets and other fixtures. These pipes get smaller as the demand for water gets lower at every stage. Our circuits work the same way. While the 40106 works just fine at 9v, the LED uses 3.3v. The 2.2k resistor in series with the LED in the previous circuit reduces the electrical flow to the LED the same way the smaller pipe reduces the available water to the fixtures in our plumbing system.
Sometimes a plumbing fixture needs to store a small amount of water to accomplish its task. Your toilet has a tank that holds water to allow it to flush. Your hot water heater has a tank of water to insure a steady supply of heated water. Capacitors work in a similar way. They are like tiny rechargeable batteries. The value of a capacitor, measured in farads, is similar to the size of a plumbing fixture's tank. The higher the capacitor's value, the more electricity it can store.
Let's consider our oscillator circuit again. The capacitor charges at a rate determined by the amount of electricity available. When it is 'full' it discharges, or 'empties', allowing it to fill up again. The larger a capacitor's value, the longer it takes to 'fill up'. This rate is also affected by the resistor component of the circuit. The higher the value of the resistor, the less electricity available to charge the capacitor and the longer it takes to charge. By adjusting the values of the R/C component of your oscillator, you can get everything from slow clock signals to audio signals and even higher frequencies. The best way to understand how this works is to try swapping components with higher or lower values and see how it affects the signal. Either hook up an LED to see the pulses or hook it up to an amplifier to hear them. Play and learn.
Step 6: Building the LFO
Look at the LFO schematic and diagram above. This should all make sense by now. The main difference here is that we're outputting to a PC817 optocoupler*. This is a very useful 4 pin chip. It's basically an LED and a phototransistor sealed in a light-proof package. A phototransistor is similar to an LDR, but it is able to switch from light to dark much faster. This makes them very useful for switching operations. When voltage is sent from one circuit to light the LED it allows a signal to flow from another circuit through the phototransistor like a switch. In this example a timer oscillator causes the LED inside the PC817 to flash at a rate determined by the potentiometer. If we run the output of the audio oscillators through the phototransistor of the 817 the audio will pulse off and on rhythmically.
Wire the circuit as suggested in the above diagram. Mount the PC817 on the same circuit board as the CD40107 and solder on some 5-6" leads, connecting pin 1 to the output of the LFO circuit, pin 2 to ground. Connect the output of the two audio oscillators to pin 4. The lead on pin 3 will connect to the output stage in the next step.
Test this out on a breadboard like before to make sure it works and then go to the next step.
A note on optocouplers-
I use the PC817 because I got a really good deal on them and they are very efficient. You can also make your own. Tape an LED to an LDR face to face. Cut a short length of heat shrink tubing that's just a little bit longer than the body of the LED and the LDR. Shrink the tubing around the components and seal the ends by squeezing the hot tubing flat over the leads with a pair of pliers. This will work just as good as an 817 in this circuit.
The 330ohm resistor used here can be changed depending on the components you choose (in reality I used 2.2k). This resistor will affect the R/C values a bit and it will also affect the 'mark/space ratio'- the length of 'on' pulses vs. the length of 'off' pulses. Play around with this value and see what you like- just don't go below 330ohms to protect the LED.
Step 7: Putting It All Together
Now we have the main part of our circuit assembled. Here we will connect the output stage, the power and the LEDs. Look at the diagram above for a suggestion for hooking up the LEDs, audio out jack, volume, LFO switch and power switch.
First, wire up the LFO switch, volume pot, audio jack and power switch. Save the LED stalks and ground bus for last so the long stalks don't get in your way. Using a stand-off of some sort mount the circuit board to the wooden block and add a way of securing your battery. I use a small piece of adhesive velcro, peeling and reusing the same piece when I exchange the battery.Also, use a few zip ties or strips of tape to keep your wires neat and secure. When all of the other inside work is done install the LED stalks.
The LED stalks are inserted into the corresponding holes in the box, with the bare copper and the LED lead sticking into the inside of the box. Using needle nose pliers make a small loop in the thick copper LED ground wires and bend them at a right angle to lay flat against the wooden block. Drill a pilot hole in the wood in the center of each wire loop ans using small screws and washers, attach the wire loops securely to the wooden block. This will form our ground bus and mount the LED stalks securely. Before you screw the loops down completely, insert a strip of bare wire to connect each ground wire loop. Make a small loop in the bared end of your battery clip's ground lead and slip it around one of the screws and tighten it. Do the same with the ground from the circuit board and the second screw. Finally connect the ground from the audio jack to the third screw and tighten.
Plug a battery into the battery clip, plug in the amplifier and turn your device on. If everything works you should have blinking LEDs and changing audio creating complex melodic patterns that you can change by adjusting the various controls. Play around and see what it does then go to the next step for an explaination of what's going on..
Step 8: How It All Works
Let's look at the LED stalks and their affect on the sound. The blink rate of each LED can be controlled independently with a potentiometer. At any time, any of the three LEDs could be on or off. Let's imagine that the three LEDs are at an equal distance from the sensor and each provides an amount of light that we will call '1'. If two LEDs are lit the sensor receives twice the amount of light and All three LEDs provide three times the light. Lets imagine further that we set the first LED to blink at one second intervals, the second one to blink at two second intervals and the third to blink at a three second interval. See the illustration above. Since the pitch created by the audio oscillator is dependent on the amount of light hitting the sensor, we can imagine the oscillator producing three notes- 1,2 and 3, depending on how many LEDs are lit.
Since distance affects the pitch as well, we can set the LEDs at different distances from the sensor to get an even larger variety of notes. See illustration 2 above. If LED 1 was 1 inch from the sensor, LED 2 was 2 inches from the sensor and LED 3 was 3 inches from the sensor, we would get more than three possible notes as the potential light values/ note value sums would be greater.
Keep in mind that syncing the oscillators is very hard. This means that you will get much greater variety in melodic patterns that change over time. Play around with careful LED rate adjustments and see what you can get.
Now let's look at the dual audio oscillators. The position of the LED stalks can affect more than just note value. An LED can be adjusted to shine more on one sensor than the other, having an unequal affect on the two pitches. An LED can also be adjusted to shine on only one of the sensors for an interesting effect.
You can also use the range adjusting pot to tune the two audio oscillators. They can be tuned to harmonize. They can also be tuned to create beat effects, where two slightly out of tune frequencies rhythmically reinforce each other. This effect is similar to the pulsing you hear when you are tuning a guitar and the notes come close to being in tune. This gives the sound more texture and rhythmic depth.
Now let's look at the LFO. The LFO turns the sound of the oscillators on and off at a rate determined by the potentiometer. Setting it at a higher speed produces a tremolo effect. Slowing the rate down creates a classic LFO effect common to electronic music.
By adjusting all of the controls carefully you can produce pretty complex patterns and sounds. The best part is that if it gets boring you can always modify the circuit for more features. Try adding another 40106 and more LEDs and oscillators. Try combining two oscillators for frequency modulation. Add 8 LED stalks and control them with a CD4017 decade counter to make an optically controlled sequencer (here's my Medusatron- Instructable coming). Try controlling other audio circuits, like the awesome Atari Punk Console or some other 555 circuits. Put your LDRs on stalks also for more versatility. Use external light sources and effects to add even more variety and chaos to your sound. Go nuts and if you come up with something cool let me know.
Step 9: What Do You Think?
Let me know what you think of this Instructable. This is only my third one so any constructive criticism is greatly appreciated. If you see any mistakes or confusing parts let me know and I'll do what I can to fix it. If you have any ideas for expanding or modifying this project let us know in the comments. If you build something inspired by this project please let me know and send pics or vids.
Second Prize in the
Battery Powered Contest
Participated in the
Participated in the
Green Design Contest
Participated in the
Featured Author Contest: Tarun Upadhyaya