i''ve connected 6 leds to the breadboard all powered by the current from 13. but i don't know how to set each individual on and off (other than just connecting 6 leds to different ports,13,12,11....). is there a way to do it through programming? because i am looking forward to building 8x8x8 led cube.
is there a way to do it through programming?
Without external hardware? No.
With external hardware (multiplexer)? Yes.
yangfizz: i''ve connected 6 leds to the breadboard all powered by the current from 13. but i don't know how to set each individual on and off (other than just connecting 6 leds to different ports,13,12,11....). is there a way to do it through programming? because i am looking forward to building 8x8x8 led cube.
You are using the word port when you should be using the word pin, port has a different meaning. Also pins on an arduino have limited current ratings and trying to operate 6 leds from one pin (as in pin13) can damage the pin in short order. To control leds independently they need to be wired to different pins, have series resistors wired to the leds, and your software sketch will operate the pins using digitalWrite() commands. It sounds like you are a beginner to software programming and electronics, is that correct? If so you need to start with the basics and learn to program and how to select and wire up very simple circuits. A 8x8x8 LED cube is a very advance project and not suitable at all to beginners in programming or electronics.
This board could do it for you. Its basically an Arduino (uses external USB/Serial adapter to load up a sketch, or load via the ICSP header) and up to 12 TPIC6B595 drivers that can sink lots of current. 96 outputs available if all parts are populated. So you'd make up 8 layers of 64 LEDs. Each layer would have a common anode, and the 64 cathodes would go to a current limit resistor and then a TPIC6B595 output. Each LED in a column would have its cathode connected to the one above it. One anode at a time is turned on to supply current to the layer - use a P-channel MOSFET with its Gate pulled low by a TPIC6B595 output to turn it on, and a pullup resistor to +5 toturn it off. If all 64 LEDs are turned at max current of 20mA, that'd need 1.28A. This MOSFET would do nicely; with on-resistance of 0.041 ohm at 4.5V switching levels, the part would dissipate 0.041ohm * 1.28A = 53mW of power, so heat sinking would not be needed. http://www.digikey.com/product-detail/en/NDP6020P/NDP6020P-ND/1055922
SPI.transfer()'s are used to control the shift registers. To control the multiplexing, every 4mS you would do a set of transfers:
digitalWrite (outputEnable, HIGH); // turn off all drivers digitalWrite (slaveSelect, LOW); SPI.transfer (anodeSelect); // 1 of 8 bits would be low SPI.transfer (byte1); SPI.transfer (byte2); SPI.transfer (byte3); SPI.transfer (byte4); SPI.transfer (byte5); SPI.transfer (byte6); SPI.transfer (byte7); SPI.transfer (byte8); digitalWrite (slaveSelect, HIGH); // moves data to output drive latch digitalWrite (outputEnable, LOW); // turn on all drivers
The digitalWrites could be replaced with direct port manipulations also to really speed things up. For this particular card, outputEnable is on PB1 and slaveSelect is on PB2:
PORTB = PORTB | B00000010; // makes PB1 high PORTB = PORTB & B11111011; // makes PB2 low SPI.transfers... PORTB = PORTB | B00000100; // makes PB2 high PORTB = PORTB & B11111101; // makes PB1 low
The rest of the 4mS, you'd prep your data for the next write out. update the anodeSelect for the next layer, etc. Receiving data from the serial port, reading buttons, doing math for fancy ripples, whatever.
I just got 10 in, $6 for a bare board mailed to US locations, overseas a little more, depends on the country. Build up as you wish with sockets or no, male/female headers or just wire right to the board, etc. paypal is fine for payment.