Using Arduino Software to serial read two Lilypads at the same time

First of all, I am working on a project where I would like to use two lilypad arduino and two bluetooth serial modules to send information to the Arduino software on my laptop. From there I would like to use Processing software to read the serial information to set off a basic sketch (essentially recognize on/off). I am using capacitive touch for my serial read information. I have gotten the capacitive touch "buttons" to be read in the serial monitor in the aruduino software already. For now the on/off function is determined based on the threshold that I program it to have.

The reason I would like to have two running at the same time is I would eventually like to design a two person game in Processing that could use both as video game controllers. For now this is a very basic prototype for a "duck hunt" sort of game where the trigger is set off by capacitive touch.

So first of all my question would be, is it possible for an arduino sketch to recognize input from two different serial reads? In this case I'm using two bluetooth mate silvers and two lilypad 328 arduino. I have been able to get both working individually with my laptop, but I do not know if it is possible to run both at the same time in one sketch or at the same time in two identical sketches. Does anyone have any information on if this is possible and how I might set this up. I have little background on using arduino and rewriting sketches, so any help or references would be greatly appreciated.

My second question would be, if I can not get two serial monitors to read two different inputs (which I'm guessing I can't), is there a way that I could instead have bluetooth1 talk to bluetooth2, which would then relay both sets of data to the sketch?

Here is the sketch I have so far that I've pieced together from several resources:


#include <CapTouch.h>

/* CapTouch - an example for the CapTouch class

  • from the v.04 - Capacitive Sensing Library for 'duino / Wiring
  • by Paul Badger 2-3-2012
  • paul@moderndevice.com The MIT License – Open Source Initiative
  • This capacitive sensing method requires two microcontroller pins (send pin, receive pin)
  • with a high value resistor between them (1M is a starting point)
  • a small capacitor (20-40 pf) from the receive pin (the sensor is connected to this pin)
  • to ground will result in more stable readings. Sensor is any wire or conductive foil
  • on the receive pin.
  • Also demonstrates a simple smoothing filter which is not required in any way
  • by the sketch
    */

// CapTouch(sendPin, receivePin) - recieve pin is the sensor to touch
CapTouch touch_2_4 = CapTouch(2,4);
int ledPin1 = 13;

float smoothed;

void setup()
{

Serial.begin(9600);
Serial.println("start");

}

void loop()
{

long start = millis(); // scheme to time performance, delete at will
long total1 = touch_2_4.readTouch(15); // read the sensor
long elapsedTime = millis() - start; // scheme to time performance, delete at will

if (total1 < 40) {
digitalWrite(ledPin1, HIGH);
delay(100);

} else {
digitalWrite(ledPin1, HIGH);
delay(50);
digitalWrite(ledPin1, LOW);
delay(50);
digitalWrite(ledPin1, HIGH);
delay(50);
digitalWrite(ledPin1, LOW);
delay(50);
digitalWrite(ledPin1, HIGH);
delay(50);
digitalWrite(ledPin1, LOW);
delay(50);
}

// simple lowpass filter to take out some of the jitter
// change parameter (0 is min, .99 is max) or eliminate to suit
// you need a different "smoothed" variable for each sensor is using more than one
smoothed = smooth(total1, .95, smoothed);

Serial.print(elapsedTime);
Serial.print(" ms ");
Serial.print(total1);
Serial.print(" ");
Serial.println(smoothed); // print sensor output 1

delay(5);
}

// simple lowpass filter
// requires recycling the output in the "smoothedVal" param
float smooth(float data, float filterVal, float smoothedVal){

if (filterVal > 1){ // check to make sure param's are within range
filterVal = .99;
}
else if (filterVal <= 0){
filterVal = 0;
}

smoothedVal = (data * (1 - filterVal)) + (smoothedVal * filterVal);

return smoothedVal;
}


Thank you for any help or references that may be of use for this project. Please let me know if you would like any further information on the project and its design.

-W