Hey I am new to the Arduino scene and came across it as a good solution to a project I have in the works. After looking at the specifications it appears that there may not be enough inputs/outputs as I need.
My project needs 20 LED's to work independently of each other. Nothing fancy just on and off. I also need 20 inputs for a sensor controlling each LED. Obviously there is a problem here as this would require more I/O pins than are on the Arduino board.
After doing some research multiplexing might be what I am looking for. This link... paulm.com/inchoate/2008/03/arduino_showing_multiplexed_led_mat.html was one of them I came across that shows 20 LED's being controlled without any extra hardware. It also appears to use only a few of the I/O spots which might free up more room for other purposes.
Can anyone give me some more information on multiplexing and the theory behind it with the Arduino? Any other links that would help me understand it?
If you don't need any serial inputs, serial outputs, analog inputs, interrupt inputs, button inputs, you can directly control 20 LEDs with no additional hardware (except the current-limiting resistors).
If you only need the APPEARANCE of full on/off illumination, you can use a technique called charlieplexing. For any n output pins, you can control n2-n LEDs. However, I say the "appearance" because you're really only lighting one LED at a time, and you can cycle through the whole pattern really fast to hide the illusion. No additional hardware except the current-limiting resistors.
If you don't have enough pins, and charlieplexing is unworkable, it is usually because you need every light to be on at the same time or the LEDs are moving very fast so they will appear to flicker. In this case, you will need to add I/O extender components, like a latch 74HC595 or such, for every eight LEDs.
Yes the arduino only has a limited amount of PARALLEL I/O lines but lines are also capable of serial,I2C and SPI communication, which would allow you to expand your I/O to suit your needs.
I was looking at charlieplexing and that appears to be what I am looking for. I will start some testing and see what I come up with. As for the the input i'm still uncertain because the charlieplexing seems to go on the fact that LED's light only in 1 direction. This would be a problem as the input switches won't benefit from this so I can't just charlieplex them. I suppose I could just have the switch right in the circuit instead of the software but I was hoping to be able to detect all of the inputs individually so I could do a nice flashing sequence while all of the switches are off.
If you only expect one button at a time to be pressed, then it's typical to wire these in matrix fashion. Then for m*n buttons, you need pins for m outputs and n inputs. A similar scanning looping method: provide HIGH on one of the m pins, and sense which of the n pins passes your HIGH signal through.
This is not the case as each of the 20 inputs can be on or off at any time independent of the others.
But I just had an idea while searching the Arduino website. What if I used a keyboard as the input? Since I won't be needing the usb slot for anything during normal operation I could run it from there. Furthermore, the sensors I need are for weight so I would be killing 2 birds with 1 stone as only some small modification would be needed but the sensors are pretty much there to begin with.
I am going to take a look at the keyboard libraries and see what I can come up with. Anyone every try a keyboard as input?
The 20 independent switches plus even one LED exceeds the 20 I/O ports of the board. If you use a keyboard that manages switches for you, you are using extra hardware.
Ok you got me there, I should have been more specific in my definition of hardware. But am I correct in concluding that a keyboard in itself is a multiplexer as it reduces all of the input down to a few wires? Furthermore that means I should not have trouble now fitting all of my input (from the keyboard) into only a few spots on the Arduino board leaving the others free to do my lighting because I will only need 5 or 6 wires as the input is in the form of usb? Also will I be able to hook the keyboard straight into the usb port or will I have to cut it apart and put it in the I/O slots. If I was able to put it only in the usb slot it would greatly reduce the complexity of the lighting portion.
The Arduino would have trouble implementing the full USB HID to support all features of a USB device like a keyboard, but you can probably get a PS2 converter and wire that up instead. I don't know of any examples of that being done, however.
Standard PC keyboards also manage the keys in a matrix format, and there are many key combinations that will NOT produce output properly. A given keyboard might not be able to indicate to you that the A and G keys are both being held, for example. There is a full microprocessor inside the keyboard, trying to minimize the issue with clever tricks, but you still won't get 100% independence.
I was just looking at this page Arduino Playground - PS2KeyboardExt and the keyboard idea came to my head. I may just end up splitting the project into 2 separate systems. 10 switches and 10 LED's for each. The project is a beer pong table so each side would not have to interact with the other. This may be the simplest solution as was mentioned earlier that 20 I/O's could operate without having to do anything complicated or with external hardware.
I used 4 MCP23016 chips on the I2C bus to give me a total of 64 extra I/O lines using only two of the Arduino's I/O pins. You can easily fit 8 of theses devices on the bus without resorting to any trickery. That's a total of 128 none multiplexed I/O lines each capable of driving a LED directly.
Yeah I was looking at the illuminato and that seems to be what would be easiest for me with little experience. Only problem is they are all out of stock and I would like the board asap.