Light triggered audio project

Hi all,

I'm very new to this (so please excuse my lack of technical terms!), and am trying to build an audio project for a university module.

I've done some of the more basic tutorials and they've all worked, and have basic coding knowledge, so hopefully I'll be able to get to grips with it asap! :-\

Right, my aim is to have 8 boxes (approx 8” x 8”) - each with a hole in the top. I want to have a photoresistor in each box that will trigger a sound when the hole is covered (less light gets in). The sounds need to be able to play simultaneously, and start/stop individually according to the amount of light getting in to each box. (I hope I'm making sense!)

So far I've used this:

int photocellPin = 0;
int photocellReading;

void setup(void) {
Serial.begin(9600);
}

void loop(void) {
photocellReading = analogRead(photocellPin);

Serial.print("Analog reading = ");
Serial.print(photocellReading);

if (photocellReading < 500) {
Serial.println(" - Play");
} else {
Serial.println(" - Stop");
}
delay(1000);
}

Which seems to be working (as a basic starting point!)

My next couple of tasks are:

  1. Getting the sound to play when the photocellReading is low. This is where I need you advice please! Is there a (simple??) way of getting a sound to play through a pc? Maybe a .wav? If I can get this working then I'll be one step closer to my goal.

Do you think there will be a way of getting multiple sound files to run at once? Any possible solution suggestions (if this is a problem) would be very very much appreciated!

  1. Hooking up multiple photoresistors, so that multiple sounds can be played. I will no doubt run into problems here(!), so if you can see any obvious flaws in this plan please do give me a heads up! Is there a maximum number of ‘boxes’ a could have from one Arduino board?

I'm hoping to make this in to a large audio installation, and plan to make ceramic boxes and a specialised wooden table. This is where my strengths lie, so any help with the technical side of things would be greatly appreciated!!! :slight_smile:

Thank you in advance :slight_smile:

(If I haven't been clear, or haven't given enough information, please feel free to (call me an idiot) ask for a clearer description ....)

Feel free to answer only part of this if you want! :slight_smile:

Task 1: You could use Processing, and the Minim library.

http://code.compartmental.net/tools/minim/

Task 2: There are six analogue inputs on a Uno, and sixteen on a Mega. There are analogue multiplex shields (like Critical Velocity - MonsterMux 32 Channel Analog Multiplexer Shield Kit for Arduino P/N: MMUX32) available for the Uno to extend the number of inputs.

Is there a (simple??) way of getting a sound to play through a pc? Maybe a .wav? If I can get this working then I'll be one step closer to my goal.

If you are using a PC, I'm not sure how you get the application running on the PC to interact with the Arduino... Maybe someone else can jump-in and advise on that.

If you can get the Arduino communicating with the PC, then the Arduino will be a good, inexpensive, way to "collect" the digital or analog from your optical sensors.

There are special-purpose cards/devices for connecting sensors (and relays, etc.) to a computer, and with something like that, you wouldn't need the Arduino. You should find this stuff if you look-up "data acquisition" or "data acquisition and control". These things come with drivers (and probably a software development kit) so getting the "information" into the computer fro use by yoru application is easier. The bad news that this stuff can be very expensive.

Since you are using a computer, it should be no problem to generate or play multiple sounds at the same time. As long as you know how (or you can learn how) to program in Visual Basic or Visual C++, and how to make your application communicate with the soundcard driver.

To do something like that without the computer, the Arduion by itself is only good for generating fairly simple square & rectangle wavforms. To play mp3, WAV or MIDI sounds, you'd need an additional audio "shield". And for multiple sounds, you'd probably need an Arduino & audio shield for each of your boxes.

I'm not sure how you get the application running on the PC to interact with the Arduino...

Serial port.

Ive found out that the most efficient way of producing sounds from the computer itself is to setup a MIDI interaction beneath the computer and the arduino.

Here is a link, that will tell you how you can easily use your USB cable to send USB messages (dunno what to call it) and convert it to MIDI messages.
http://spikenzielabs.com/SpikenzieLabs/Serial_MIDI.html

Thank you so so much for your replies. It's great to have people to steer you in the right direction!

I'm looking into the Processing/Minim route at the moment. BUT surprise surprise I've hit a hurdle already (It must be so frustrating dealing with newbies .... sorry!)

Would you mind clarifying what the processing-Arduino link is? I've been searching everywhere, but everything online seems to assume basic knowledge (which I clearly don't have lol). Am I right in think that I should use the Arduino Environment to control the actual board (pull in light sensor information), then pass this information to Processing - where the audio will be controlled? I've thought for the last few days that Processing was something used to control the Arduino board directly :-\

My next hurdle (I have a feeling this is going to be a long journey!) is getting Processing working on my computer. The only guide I can find is here: Arduino Playground - Processing. It seems pretty clear (bonus), but unfortunately it doesn't seem to pan out. I've downloaded the processing-arduino.zip as stated, and un-zipped it, but there is no 'Firmata' in 'Examples' ..... or anywhere else for that matter. Firmata seems to be key in getting the arduino and processing communicating with one another, so I'm not sure what to do!! Do you have any advice or suggestion please?

Also, one other quick question, the instructions on arduino.cc keep referring to the Processing Sketchbook e.g. '1.Unzip the library and copy the "arduino" folder into the "libraries" sub-folder of your Processing Sketchbook.' Does this mean the main Processing directory that I downloaded?

Thank you!!!!