Hi all,
Let me begin by telling you I'm on a learning curve and that my question might seem stupid. In that case, I apologize in advance and please tell me so!
So, I've done my fair share of searching and trying out, but I'm stuck on something I can't get my head around. This is the case:
I control (in this example) a serie of 5 DMX controlled LED pars. Something like this. Each par takes 6 channels for which the first 3 are to control the R,G and B levels per par.
I control DMX via the Tinkerkit DMX shield. It's fairly easy.
DmxMaster.write(channel, value)
So to control one par I could do
for (i=0;i<3;i++) {
DmxMaster.write(i,255);
}
And I would have one light with all LED's full on. Please, understand, this was a breakthrough for me ![]()
I can do the same thing off course for multiple par's as long as I skip the extra channels. Those are used to alter the mode, strobe effect, and RGB simultaneous. So the second par would start on channel number 7.
My goal is to make a simple VU meter, with soundlevels measured via microphone. I have some thing working, but it's not pretty. I have 5 par's, but need 6 channels, because the 4th par needs to be yellow. The microphone value's are scaled to 0...255. I use a dirty fix I guess to make the par's go from green at the bottom to red on top. The channels are in reversed order here, the light with channel one is actually on top.
if (inten < 20) { //lowest value
DmxMaster.write(26,inten);
DmxMaster.write(20,0);
DmxMaster.write(14,0);
DmxMaster.write(8,0);
DmxMaster.write(7,0);
DmxMaster.write(1,0);
}
else if (inten < 40) {
DmxMaster.write(26,inten);
DmxMaster.write(20,inten);
DmxMaster.write(14,inten/2);
DmxMaster.write(8,0);
DmxMaster.write(7,0);
DmxMaster.write(1,0);
}
else if (inten < 80) {
DmxMaster.write(26,inten);
DmxMaster.write(20,inten);
DmxMaster.write(14,inten);
DmxMaster.write(8,inten);
DmxMaster.write(7,inten/2);
DmxMaster.write(1,0);
}
else if (inten < 120) {
DmxMaster.write(26,inten);
DmxMaster.write(20,inten);
DmxMaster.write(14,inten);
DmxMaster.write(8,inten);
DmxMaster.write(7,inten);
DmxMaster.write(1,inten/2);
}
else if (inten < 160) { //highest value
DmxMaster.write(26,inten);
DmxMaster.write(20,inten);
DmxMaster.write(14,inten);
DmxMaster.write(8,inten);
DmxMaster.write(7,inten);
DmxMaster.write(1,inten);
}
The problem with this method is the lack of possibilities to ease values, and it takes so much code. I bet I can do this better. The final result will use over 30 par's and multiple sensors, I need to write it as effecient as possible. What I can't seem to manage is the fact that it needs to change color above a certain value, but only in one light, not all.
I'm looking for some good advice on this matter, as it will help me a great deal in the rest of the project!