Pages: [1]   Go Down
Author Topic: Interactive light sculpture  (Read 10132 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

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
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8821
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Didn't you like the answer I gave when you posted this same question in http://arduino.cc/forum/index.php/topic,140530.0.html ?
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Pages: [1]   Go Up
Jump to: