arduino/processing serial communication being slow

I’m working on a project in which I have letters painted out in conductive ink. These letters act as a capacitive sensor, so whenever anybody touches them, pitches get played through a piezo transducer and Processing graphics are produced on my computer screen—the graphics and music change accordingly with the sensor values.

However, I have a problem. When I have these programs written for ONE sensor only, they work fine. When I have them written for TWO ink sensors, then the graphics in Processing are really, really, REALLY slow. Does anybody know why that is and how I can fix it? I’m going to be connecting six sensors to this thing, eventually.

I’ve attached the programs that I wrote for one sensor only (sketch1.pde and CapSound_singlesketchtest.pde) and the programs I wrote for two sensors (processingSerialCom4.pde and CapSound4.pde).

CapSound4.pde (4.08 KB)

CapSound_singlesketchtest.pde (3.95 KB)

processingSerialCom4.pde (1.75 KB)

sketch1.pde (852 Bytes)

Also, here’s the .h file for the pitches.

pitches.h (1.96 KB)

Hi, I have my arduino connected to two sensors that are controlling the graphics in a Processing program. However, the graphics are SUPER slow. I have no idea what could be causing this problem. Please help! My project is due in a couple of hours. I’ve attached my code to this message.

CapSound4.pde (4.08 KB)

pitches.h (1.96 KB)

processingSerialCom4.pde (1.76 KB)

Make this 9600 higher?

Serial.begin (9600);

andd
port = new Serial(this, "/dev/cu.usbserial-A700fiDh", 9600);

The speed of the graphics are unlikely to be an Arduino problem

CrossRoads, I don't understand what you are suggesting.
AWOL, what do you think it could be?

We’re both saying the same thing - increase the speed of the serial link.

I just changed it to 12000 and now Processing is giving me an error: “Error inside Serial.()”

Try 19200, or 38400

Try 19200, or 38400

Or go for all the marbles and set it at 115200.

I tried, and it doesn't really help. :confused:

Some more detail?

I tried changing the baud rate BOTH in line 11 of my Processing code and in line 32 of my Arduino code to 19200, then 38400, and it didn't do anything to change the pace of the graphics—if anything, it only made them move more slowly.

So, you may want to change the subject line of the thread, or start a new one.

Hi, I have my arduino connected to two sensors that are controlling the graphics in a Processing program. However, the graphics are SUPER slow. I have no idea what could be causing this problem. Please help!

The files are here: http://allotrope-dome.net/sketches/

Those "delay(50);" - are they helping?

Can I also recommend using the auto format tool before posting code?

( you're setting pinMode on pin zero as INPUT. You don't want to do that.)

I just tried removing those delays, and they don't seem to have much of an effect on the program at all. The only reason I put them there was because the guy in the tutorial I was watching told me to.

I also removed pinMode(photocell, INPUT). It doesn't seem to have a significant effect on the program, either—but tell me, why is it a bad idea to do that?

Okay, in the future I'll try to do that before posting code.

He already has another, earlier, thread:

Meanwhile, we seem to be continuing here:

It doesn't seem to have a significant effect on the program, either—but tell me, why is it a bad idea to do that?

Of itself, setting pin zero to be an input isn't a bad idea, it is, after all, the serial line Rx pin.
But you're not referring to the digital pins, because your "pin zero" is an analogue pin.

… which has now been deleted it seems. Well that accounts for why a message I had typed was stuck in “Fetching Preview” for 10 minutes. Fortunately I made a copy …


There must be an easier way than this:

 if(total1 > 50 && total1 <= 100)
      tone(8, NOTE_C7);
    if(total1 > 100 && total1 <= 150)
      tone(8, NOTE_CS7);
    if(total1 > 150 && total1 <= 200)
      tone(8, NOTE_DS7);
    if(total1 > 200 && total1 <= 250)
      tone(8, NOTE_E7);
    if(total1 > 250 && total1 <= 300)
      tone(8, NOTE_F7);
    if(total1 > 300 && total1 <= 350)
      tone(8, NOTE_FS7);
    if(total1 > 350 && total1 <= 400)
      tone(8, NOTE_G7);
    if(total1 > 400 && total1 <= 450)
      tone(8, NOTE_GS7);
    if(total1 > 450 && total1 <= 500)
      tone(8, NOTE_A7);
    if(total1 > 500 && total1 <= 550)
      tone(8, NOTE_AS7);
    if(total1 > 550 && total1 <= 600)
      tone(8, NOTE_B7);
    if(total1 > 600 && total1 <= 650)
      tone(8, NOTE_C8);
    if(total1 > 650 && total1 <= 700)
      tone(8, NOTE_CS8);
    if(total1 > 700)
      tone(8, NOTE_D8);

Anyway, on this page:

http://www.arduino.cc/playground/Main/CapSense

it says:

The capSense method toggles a microcontroller send pin to a new state and then waits for the receive pin to change to the same state as the send pin. A variable is incremented inside a while loop to time the receive pin’s state change. The method then reports the variable’s value, which is in arbitrary units.

I worry when I read about a library that “waits for the receive pin to change to the same state”. Now if you are doing that for lots of sensors, won’t that be slow?

I also removed pinMode(photocell, INPUT). It doesn’t seem to have a significant effect on the program, either—but tell me, why is it a bad idea to do that?

Analog pin 0 is A0, not 0 - when using pinMode. You are setting D0 (digital pin 0) to input.