16 lights

I would like to use a Decimila to fade 16 leds, each with a separate potentiometer. I'm pretty new to Arduino, but have done some programming and building with basic stamps...

Am I on the right track here, at least in the early planning stages:

Use two 4051 multiplexers to make 16 analog inputs for my pots, then drive the leds with a tlc5940?
Are there power concerns I need to think about?

Thanks for any help,

Carlos

So far so good, power is just about on as well. Sounds like you have a project although what is the application?

If the only goal is to control LEDs light intensities with pots, you could do it without any IC / Arduino.

Yes but it's not as much fun is it and he probably wants to do more. :wink:

Hi, Thanks for the quick reply!

I would like to make a led light controller for stop motion animations that I am making - for this particular one, I am animating fireflies, so I need to be able to adjust a group of leds one by one, then have them stay at that particular intensity while I shoot. Then I adjust again, shoot again...

If there is a much easier way, I would probably go that route (let me know!), but I thought that this might be a way of doing what I need to do but allowing for further expansion. I could, for example, set up the code so that intensities change at a fixed rate when I push a button if I wanted to use the lights for a tiny theater marquis or something?

I've done some led control with arduino before but I am at a very basic level.

My thinking is the code will work, in the most elemental form, like this:

set up the inputs and outputs for the 4051 and tlc5940

make a loop that runs 16 times

check an input on the 4051
scale the value
output to the 5940

top of loop

Still on track?

Thanks,

Carlos

ps is there any advantage to using a MC14067BCP (16 channel multiplexer) over two 4051's?

is there any advantage to using a MC14067BCP (16 channel multiplexer) over two 4051's?

Not much.

How about writing a the program so that it sends each frame's information back to the computer and then have a processing program collect that data and store it so you have a record and you can play it back.

What is more how about just using one pot and a rotary encoder and a few more LEDs to select what LED you want to work on with the knob. Or do that with only a row of 4 knobs.

Are the LEDs just a single colour? I used 16 RGB LEDs in a matrix for this project:-
http://www.thebox.myzen.co.uk/Hardware/Mini_Monome.html

You could even do all the control stuff in the computer with a mouse and sliders and fire off the data to the Arduino to light up the LEDs.

That's beautiful and fabulous too. Nice photography also.

I think the advantages to a system like you suggest, computer interface, are great, but the complexity grows, and I have a semester as an artist in residence to work on these animations... I can see the entire period swallowed up in learning how to set up the computer connection.

I spent a lot of time on this project:

http://www.carlosferguson.com/Pages/Artwork/Recent/Little%20World/LittleWorldStill.htm

and want to make something simple, yet functional.

The multi-pot setup seems necessary. Controlling things in animation is a process of tiny increments - easier to do by feel than by sight sometimes, so it is good to have a separate pot for each light so it can be tweaked just so when you want to turn it up or down.

So I think you are saying that the code and complexity are the same for two 4051's or a 16 channel multiplexer like the 4067?

Carlos

Very impressive work.

I should go with what you are comfortable with, I was only trying to cut down on the hardware you had to buy and make.

There is not much in the two multiplexers. The only thing is using the two 4051s (you don't need an apostrophe (I am marred to an English teacher)) will use two analogue inputs but that's no problem.

For this kind of arrangement, there's one benefit of a computer-based solution: reproduceability.

If you program the sketch to output the level of every star/fly/light when you take a shot, then you can return to the same exact situation where required.

For example, if you animate the boy and his dog (and the fireflies) for frames 0 to 200, but realize that the dog's tail has been forgotten for the last five frames, you can "rewind" all your firefly changes by looking at the log and dialing in the same patterns. You could go even further and make the sketch able to read its own logfile format or rewind frame by frame to automate this process.

I agree, and can see that it would be a perfect solution to just the situation you are describing, I just think the overhead in learning the connection between computer and arduino might be too great though... am I wrong about this? Wouldn't this also require writing programs for my computer to make an interface?

Thanks,

Carlos

1 Like

Hello again,

I wonder if anyone could verify again that I am on the right track?

My plan is to get the arduino working with the 4051s and pots first, then add the tlc 5940.
So first, the code below, copied from the tutorial in the arduino playground.
My comments are in blue and are describe what I understand the code to be doing.

(edited) 2006 by tomek ness
for the arduino community http://www.arduino.cc

/*

  • codeexample for useing a 4051 * analog multiplexer / demultiplexer
  • by david c. and tomek n.* for k3 / malmö högskola

*/
int led = 13; //just a led
int r0 = 0; //value select pin at the 4051 (s0)
int r1 = 0; //value select pin at the 4051 (s1)
int r2 = 0; //value select pin at the 4051 (s2)
int row = 0; // storeing the bin code
int count = 0; // just a count
int bin [] = {000, 1, 10, 11, 100, 101, 110, 111};//bin = binär, some times it is so easy
This sets up a string called bin for each of the binary possibilities between 0 and 7
void setup(){

pinMode(2, OUTPUT); // s0
pinMode(3, OUTPUT); // s1
pinMode(4, OUTPUT); // s2
digitalWrite(led, HIGH); is this just to see that it is working?
beginSerial(9600);
}
void loop () {

for (count=0; count<=7; count++) {
row = bin[count]; store the string of binary numbers in row as the count progresses
r0 = row & 0x01;
r1 = (row>>1) & 0x01;
r2 = (row>>2) & 0x01;
the previous three commands are bit fuzzy for me - I assume the first sets r0 to lowest bit of the binary value, then r1 is set to the second bit value, r2 is the third bit value - but what is the & 0x01? I know the bitwise &, but don't know 0x01
digitalWrite(2, r0);
digitalWrite(3, r1);
digitalWrite(4, r2);
//Serial.println(bin[count]);
delay (1000);
}
}

Thanks for any help, sages!

Carlos

There is one possible showstopper bug with this approach. PWM LED brightness control may cause problems due to your camera shutter, since the LED is being turned on and off at full brightness rapidly.

I think if the shutter speed is long enough, 1/4 second or so? should span enough of the pulses? Will have to try.

Any thoughts on the code above?

Thanks!

I didn't test your code, but it looks like you're headed in the right direction. It's a bit of a moot point to try to engineer the code before you have the hardware to start testing it. The most you can really do for sure is to see if the Arduino IDE will pass the "Verify" (aka Compile) step.

You don't need an array to list all of the binary permutations. The number 5 is stored in memory as B00000101 already. A loop that goes from 0 to 7 will have all permutations of three bits, as is; so r1 = (row>>1) & 0x01 can just be expressed as r1 = (count>>1) & 0x01;. If you want to print that in binary, try Serial.print(value, BIN); which prints the characters for 1 and 0 automatically.

Yes, if you use a long shutter time, the PWM will average out properly. You can probably get away with 1/10sec, but since you're doing stop motion photography, you're probably using very small apertures for depth, and other low-wattage always-on lights, forcing an even longer exposure.

That makes sense ( to use the count instead of an array ), but I don't understand the "& 0x01"

What does that mean? I've searched and can't come up with the 0x01 part.

Thanks,

Carlos

Hexadecimal notation for 1.

jeez... that seems like something one should know. Thanks for the info.

but if the code in that section is just saying

r1 = (a particular bit of count) & 1

why can't it just say

r1= (a particular bit of count)

is the "& 1" to make it so you are just looking at the first bit?

Yes it's 00000001 in binary, ANDing it with anything will mask off the rest of whatever you ANDed, so if bit 1 is 1 then you get 1, etc.

Good google terms are bitwise operator, boolean logic, hexadecimal and binary code.

Hello,

I have the pots, a 4067 16 channel multiplexer and the arduino hooked to the tlc5940 which drives leds - all working!

It was a little less stressful than I thought it would be and now I am wondering about the computer control suggested earlier. Can someone describe in general how this could happen, point me towards some information?

Thanks!

Carlos

Look at http://arduino.cc/en/Tutorial/HomePage and the bit about controlling an LED through processing.

Then work out a data package to send to your arduino that defines brightness for each LED. Write in processing something to do this and change the arduino so you catch it.

Then add a button so that when you press it you send a lode of numbers from the arduino up to processing.