Hi Everyone.
I'm are doing an lighting installation for an event in Sydney this coming friday, and kinda freakin because a component of the work is using an arduino, and naturally I jumped right in with the "ive seen others do it, so Im sure I can" attitude... always a positive attitude to take imo.
We have 5 prox sensors running into an arduino uno, which is spitting out midi over tx and through a midi-usb converter and into the computer, which is controlling madrix for the lights.
So basically... you can see from the code below what I am starting with (full credit to Noah Stahl whos code this essentially is). The next thing I need to is add in 4 more sensors.. can i do that just by defining them at the start and then mirroring the code below?
Secondly, the sensors are very jumpy, so I need to do some mad smoothing, I have looked around on how to do that but i'm at a bit of a loss...
And thirdly, we just need one more control (just a note change or anything like that, not continuous controll) that fires once every two minutes, how would I do that do you think?
Heres the code i'm working with:
Code:
// Noah Stahl
// 5/25/2011
// http://arduinomega.blogspot.com
// Arduino Mega 2560
//This sketch is used to test the Sharp Long Range Infrared Sensor.
//The sensor output is attached to analog pin 15. Once the distance
//is calculated, it is printed out to the serial monitor.
#define sensorIR 1 //Must be an analog pin
float sensorValue, inches, cm; //Must be of type float for pow()
void setup() {
Serial.begin(31250);
}
void loop() {
sensorValue = analogRead(sensorIR);
inches = 4192.936 * pow(sensorValue,-0.935) - 3.937;
//cm = 10650.08 * pow(sensorValue,-0.935) - 10;
delay(100);
Serial.write(0xb0); // CC message for channel 1
Serial.write(0x5); // or what ever CC number you want to write to
Serial.write(int(inches) & 0x7f); // keep the inches from going over 127
}
And here is our installation website http://digitalwattle.co.nz/
There is a sweet test video if you want to see what we are doing!
Thanks to anyone who replies, I have to say I'm loving this community, will chuck the arduino logo on our sponsors list on our installation lightbox!
Cheers,
James