Light triggered sound box project: Advice needed!

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Light triggered sound box project: Advice needed!

Postby orange_fox » Wed May 02, 2012 10:49 am

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!

2. 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!!!

Thank you in advance

(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 ....)
orange_fox
 
Posts: 6
Joined: Wed May 02, 2012 10:46 am

Re: Light triggered sound box project: Advice needed!

Postby adafruit_support_bill » Wed May 02, 2012 11:45 am

A standard Arduino has 6 analog pins. So from a hardware perspective, your current sensor scheme could expand to 6 sensors. Going to a Mega would give you 16 analog pins. (There are other ways to expand the inputs, but I am trying to keep the circuitry simple for you)

The Arduino software would get a little more complex, but not too bad. Instead of sending a simple "Start" and "Stop", you could send serial commands specific to the sensor such as "Start-2" and "Stop-4".

On the PC side, playing simultaneous wave files is possible. You could write a program to monitor the serial port and play WAV files on command from the Arduino. You don't mention what programming environment you are using there, but here is one example using .Net:
User avatar
adafruit_support_bill
 
Posts: 16638
Joined: Sat Feb 07, 2009 9:11 am

Re: Light triggered sound box project: Advice needed!

Postby orange_fox » Wed May 02, 2012 11:59 am

Oh sorry, I'm just using the one that I downloaded when I first installed the Uno driver. I think it may be called Arduino Environment, but I'm not sure. I really am a newbie when it comes to technical terms. Like I said, I understand basic coding principles, so am able to get my head around the principles of what you've suggested, but I'm a complete novice when it comes to the lingo!! :-\ I've attached a screen shot of the environment I've been using. Is it processing? (I'm very aware that I'm coming across as an idiot lol)

So is there a function that can tell the PC to play an audio file? If I could get that working then I could probably adapt it to work for multiple files. If you have any ideas, or could give me a starting point, I'd be eternally grateful (Sorry if it's cheeky to ask this!).
Attachments
arduino_environment.jpg
arduino_environment.jpg (177.81 KiB) Viewed 785 times
orange_fox
 
Posts: 6
Joined: Wed May 02, 2012 10:46 am

Re: Light triggered sound box project: Advice needed!

Postby adafruit_support_bill » Wed May 02, 2012 12:22 pm

OK. That is the Arduino Environment. You can use it to program the Arduino and communicate with it over the serial connection, but you can't make it control the PC in any way.

The Arduino Environment is based in part on the Processing Environment. Processing does allow you to write programs that run on the PC and communicate with programs on the Arduino. I don't know if it will support playing simultaneous wav files, but someone on the Processing forum could probably answer that question.
User avatar
adafruit_support_bill
 
Posts: 16638
Joined: Sat Feb 07, 2009 9:11 am

Re: Light triggered sound box project: Advice needed!

Postby orange_fox » Thu May 03, 2012 5:50 am

Thank you!! :-)

(Would the processing environment use the same code as the Arduino Environment? .... I hope so!)
orange_fox
 
Posts: 6
Joined: Wed May 02, 2012 10:46 am

Re: Light triggered sound box project: Advice needed!

Postby adafruit_support_bill » Thu May 03, 2012 6:02 am

(Would the processing environment use the same code as the Arduino Environment? .... I hope so!)

It uses the same programming language. But there are differences in what things you can do in one environment vs. the other. (e.g. graphics & sounds on the PC vs. sensors on the Arduino).
User avatar
adafruit_support_bill
 
Posts: 16638
Joined: Sat Feb 07, 2009 9:11 am

Re: Light triggered sound box project: Advice needed!

Postby orange_fox » Thu May 03, 2012 6:19 am

OK scrap that last comment! Clearly it's not. I've had basic (very) experience with Java so hopefully I'll be able to sort something out. Would you mind just 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: http://www.arduino.cc/playground/Interfacing/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. Obviously this Firmata is key to getting the arduino and processing communicating with one another, so I'm not sure what to do!! Do you have any advice?

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!!!!
orange_fox
 
Posts: 6
Joined: Wed May 02, 2012 10:46 am

Re: Light triggered sound box project: Advice needed!

Postby orange_fox » Thu May 03, 2012 6:40 am

OK, it still looks like I'm very confused! Sorry, I think our last two replies crossed over, so I've only just seen your last post. I thought that Processing used Java and the Arduino Environment used C++ or Visual Basic.

I'm getting so frustrated with this, but am determined to persevere! If I can get my head around some of the basic priniciples and start up requirements I think I'll be ok ....
orange_fox
 
Posts: 6
Joined: Wed May 02, 2012 10:46 am

Re: Light triggered sound box project: Advice needed!

Postby adafruit_support_bill » Thu May 03, 2012 7:27 am

I don't blame you for being confused. Arduino and Processing are an amalgamation of different technologies and it is hard to see the boundaries between them sometimes. I personally am not very familiar with the processing environment. But I do know that the Arduino environment was based on the Processing code-base.

There are several systems that are designed to bridge the Processing and Arduino environments in a seamless fashion. Firmata is one of the more established ones. If you load the Firmata firmware onto your Arduino, you can essentially control the Arduino from a Processing program on your PC.

Firmata.org does not have a forum, but there are plenty of firmata users that frequent the forums at www.Processing.org and www.arduino.cc. They can probably answer some of your firmata/processing questions.

We can help you out with the Arduino side and sensor interfacing.
User avatar
adafruit_support_bill
 
Posts: 16638
Joined: Sat Feb 07, 2009 9:11 am

Re: Light triggered sound box project: Advice needed!

Postby orange_fox » Thu May 03, 2012 10:14 am

Thank you!!
orange_fox
 
Posts: 6
Joined: Wed May 02, 2012 10:46 am


Return to Arduino

Who is online

Users browsing this forum: xEDWARDSx and 13 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [114]

Raspberry Pi[82]
 
FLORA[24]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[12]
Arduino[60]
 
NETduino[14]
 
BeagleBone[23]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[39]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[9]


 
Breakout Boards[35]
LCDs & Displays[49]
Components & Parts[70]
Batteries & Power[54]
EL Wire/Tape/Panel[52]
LEDs[112]
 
Wireless[16]
Cables[66]
 
Lasers[6]
Sensors/Parts[147]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[41]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[25]


 
Stickers[41]
 
Skill badges[55]
 
Books[26]
 
Circuit Playground[7]
 
Gift Certificates[4]