Hi there,
I am building an interactive light sculpture and am in need of some help on the final stages of my work. I have 4 sfr02 ultrasonic range finders, they are hooked up to my arduino uno and are sending data back to my serial monitor with this code:
#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;
}
}
That is working brilliantly! I also have two 5m strips of leds connected to ports 5 and 6, without taking readings from the sensors I can program these lights to fade in and out etc... so I know they are wired up correctly.
I am stuck with how to get my sensors to talk to my leds. I need help with the code and I don't know where to begin! This is what I want to happen:
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