sending multiple numbers simultaneously from arduino to processing

I have a capacitive sensor program written in Arduino, and I’m using the sensor values to generate different colors in Processing. How would I go about connecting multiple sensors and conveying the signals from both simultaneously into Processing?

I’ve uploaded my Arduino and Processing programs for you guys to look at.

processingSerialCom.pde (1007 Bytes)

CapSound.pde (3.93 KB)

pitches.h (1.96 KB)

How would I go about connecting multiple sensors and conveying the signals from both simultaneously into Processing?

You can't. You can't send anything simultaneously using a serial port. One value right after the other, yes. Two values at the same time, no.

Attaching small files makes it difficult to respond to your post. Once one hits reply, the links to the attachments are gone. Simply pasting the code in the post, using the # button is better.

   if(total1 > 50 && total1 <= 100)
   tone(8, NOTE_C7);
   else if(total1 > 100 && total1 <= 150)
   tone(8, NOTE_CS7);

The first if test handled all cases where the value of total1 was less than or equal to 100. If the value in total1 was greater than 100, the first case was not executed. So, there is no reason to text that again in the second if test. The second if test will not be evaluated unless the value in total1 IS greater than 100.

Commenting out blocks of code before posting is not helpful. If you want to ask questions about the code, get rid of the stuff that is not being executed, unless that is specifically the topic of the post.

It isn’t clear exactly what you are asking for help with.

Okay, sorry if I wasn't being clear.

I changed my idea around a little, and here's what I want to do.

Here's my setup: I have three capacitive sensors made with conductive ink (this is what I'm talking about: http://www.bareconductive.com/capacitance-sensor) connected to three respective speakers. When you move your hand over each sensor, each speaker emits different noises. So far, I've only set up the first speaker, though.

I want to make it so that there are essentially three different graphical sketches in the Processing program I wrote, and a different one is activated depending on which sensor you move your hand over. If you move your hand over two sensors at the same time, it'll keep playing the sketch that corresponds to the first sensor you waved your hand over, then once you move your hand away, it'll play the sketch corresponding to the other sensor.

Does that make sense? I think I've got the speaker part down, it's just the Processing part that I'm unsure of how to handle.

TLDR: how do I write a program that generates different Processing sketches depending on which sensor you hold your hand over?

So, you want to send a Pressed event, with switch number, and a Released event, with switch number, to the PC, for each pressed and released event that the Arduino detects. This is easy.

how do I write a program that generates different Processing sketches depending on which sensor you hold your hand over?

Processing, like the Arduino, does one thing at a time. It, like the Arduino, can only have one sketch active at a time.

What is it you want these sketches to do? Most likely, the different things can be done in a single sketch, with a switch statement to select which case to execute, based on serial input.