Noise by Light

by contrechoc in Circuits > Audio

2299 Views, 14 Favorites, 0 Comments

Noise by Light

DSC07506.JPG
This instructable is about using light variation, eg caused by passing people, to produce some funny noises.

Input: light
Output: ticks, clicks and tones
Energy: two AA batteries, 3V
Brain: Attiny45

How:
Soldering
Programming

Why?
There are many gadgets with sounds triggered on light. The fun is to make use of the input in a way that it changes as much as possible depending on conditions. This is done in the coding part, where the intensity and speed of the light change the LDR receives is used for generating as much as possible variation in pitch and length and alternations.

Needed Components

DSC07495.JPG
DSC07501.JPG
DSC07494.JPG
DSC07499.JPG
Microcontroller:
Attiny45

Components:
holder for the chip
Resistor 4.7 K Ohm
LDR
PCB
Speaker 8 Ohm (for some speakers a capacitor)
some wires

Speakers
For bigger sound you can either use biggers speakers, or more voltage

Needed Tools

muts1.jpg
Tools
Soldering device
pincher

Intelligent Things:
Programmer
Laptop with AVR Studio of Gcc on MAC

Making: Soldering

DSC07504.JPG
DSC07505.JPG
Soldering the holder on the PCB

Adding the resistor, VCC and PB4
Soldering two wires for the LDR: GND and PB4
Soldering two wires for the battery, VCC and GND
Soldering two wires for the speaker, GND and PB3

So the GND has 4 wires
PB4 has two wires
PB3 has one wire.

Making: Programming

DSC07503.JPG
You can either use a programmer like mkspiII for flashing the C file to the Attiny45
or this trick with the Arduino:
http://hlt.media.mit.edu/?p=1695

Code of the Noise

Captura de pantalla 2013-05-14 a la(s) 21.38.32.png
We have two numbers for input:
  • change of light: how fast
  • length of change.
At the moment the script is using only: change of light: be creative and experiment introducing length of time of the change!

First I am reading the input value and comparing it to the former input value giving me the difference:

valueADC = adc_read(3);
diff = abs(valueADC - valueADC_old);

Pulse
Then I start a pulse depending on the difference:
if (diff > 64 )  _delay_ms(  20 );
if (diff > 32 )  _delay_ms(  4 );
if (diff > 16 )  _delay_ms(  10 );
if (diff > 8 )  _delay_ms(  3 );
if (diff > 4 ) _delay_ms(  2 );
if (diff > 1 ) _delay_ms(  1);
The delay gives me the tone pitch short delay high pitch
You can try out combinations of different pitches for different diff's.

Slow Stopping
The slow dying out of the noise is done with:
while( diff >0){
"do pulse"
diff=diff/2;
}
So getting a longer noise, going through some pitches, before stopping.

Download the code from: https://github.com/contrechoc/Noise

The LDR

DSC07505.JPG
Using the light is done by the Light Dependent Resistor, in combination with a fixed resistor.
By attaching legs of both to the input PIN PB4 and the legs of each either to the GND or the V, you get a balancing act on the input PIN.

Alternatives

For adding more sophisticated sound effect you can use the music shield for the Arduino.
Or a combination?

Then the attiny45 has too few PINS and you have to use either the Arduino board or an bare Atmega328