Controlling LEDs with 4 ultra sonic sensors

Hi there,

I am creating an interactive sculpture. I have 4 srf02 ultrasonic range finders each with with identifiable ids, 70, 71, 72 and 73. These sensors are hooked up to my arduino and via the A5 and A4 channels and feed numbers back into my computer using the serial monitor. All good so far.

I have two 5m strips of LED, one colour tape attached to external power supplies, these are interfaces with the arduino with a mosfet and are plugged into ports 6 and 5 digital pins on my arduino uno. I can control my LED tape using my arduino to turn it on and off and fade in and out. This is also all good so far.

What I need help with is my missing link, how to I use the readings from my sensors to control my LEDs. I think this bit is to do with the code I am using perhaps.

I am using this code to feed my sensor readings to my arduino:

#include "Wire.h"
#include "SRF02.h"

SRF02 srf02[4] = {
SRF02(0x70, SRF02_CENTIMETERS),
SRF02(0x71, SRF02_CENTIMETERS),
SRF02(0x72, SRF02_CENTIMETERS),
SRF02(0x73, SRF02_CENTIMETERS)
};

unsigned long nextPrint = 0;

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

void loop()
{
SRF02::update();
if (millis() > nextPrint)
{
Serial.print(srf02[0].read());
Serial.print(",");
Serial.print(srf02[1].read());
Serial.print(",");
Serial.print(srf02[2].read());
Serial.print(",");
Serial.print(srf02[3].read());
Serial.println();
nextPrint = millis () + 1000;
}
}

This works fine - what I need to know now is how to say the following in code - so that my arduino now controls my LEDs.

'When sensor's 70, 71, 72 & 73 take a reading between 0-50 turn on LED strip on port 5.

When sensor's 70, 71, 72 & 73 take a reading between 50-100, keep on LED strip 5 and also turn on the LED strip on port 6.'

I would be happy to have this communication going first but ultimately I actually want the readings to fade in and out my LEDs, see below:

'When sensors 70, 71, 72 & 73 take readings 0-50 fade in LED strip on port 5, 0 being the lowest, 50 being the brghtest.

When sensors 70, 71, 72 & 73 take readings 50-100, keep strip 5 on its brightest and fade in strip on port 6, 50 beng the lowest, 100 being the brightest.'

If anyone can help me with either of these queries, I would be much obliged.

Many thanks in advance,

Aphra

have a look at http://arduino.cc/en/Reference/Map