## Introduction: Noise by Light

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.

## Step 1: Needed Components

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

## Step 2: Needed Tools

Tools
Soldering device
pincher

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

## Step 3: Making: Soldering

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.

## Step 4: Making: Programming

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

## Step 5: Code of the Noise

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:

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.