As you can see the difference is the place of the delay(). I uploaded both codes, and both looks exactly the same, so i can assume it does not care where i place the delay?
No you was right! The latch pin should be low so no data will be send to the outputs. If i put the resistor on 5v and the latch then the latch will be high, if i tie it to GND then it is low(atleast it's working if i put the resistor between latch and ground). However i'm not sure if I need to place a resistor on every latch pin or only 1 resistor from latch to ground will be good enough (notice that all the latches from the 6 registers are tied together).
I still have a small 'problem'. The shift registers are hooked up to the arduino (3 digital pins, GND and 5V), when I put my USB cable in my laptop all the LEDS light up for a second and then just run the code I what was uploaded to the arduino. Is there any way to let the LEDs not light up whenever I connect my arduino to my laptop? Vid:
Yes I discovered I made a bad mistake what mark mentioned. Instead of pulling out the ground from the arduino I should have pulled out the ground from the LED(so stupid). Mark, thanks for the info by the way now I know even more about shift register(I am still very new with electronics so it is a kind of learning experience for me), thanks !
After finishing my 3x3x3 LED cube I decided to go a little bigger (5x5x5). Now the arduino doesn't have enough pins to control the LEDs, so I decided to use (5)shift registers to expand my number of outputs. So I was searching on the internet and found this tutorial(http://arduino.cc/en/Tutorial/ShiftOut). So I ordered a few LEDs and the 74hc595N shift register (datasheet:http://www.nxp.com/documents/data_sheet/74HC_HCT595.pdf). After wired everything (only 2 LEDs hooked up) up as the tutorial shows, everything worked perfectly fine . Because i'm gonna use 5 transistors to control the LED's layers, I pulled out the ground (pin 8 on the shift register). I expected to see the LEDs go off though they didn't. So now I pulled out the 5v aswell and still the LEDs are on (less bright though).
Now I think the shift register is provided by current through the I/O pins 8, 11, 12. Now I don't why this happening so if someone can explain it to me (why and how??) it would be very helpful!
this code i'm using:
Code:
//Pin connected to ST_CP of 74HC595 int latchPin = 8; //Pin connected to SH_CP of 74HC595 int clockPin = 12; ////Pin connected to DS of 74HC595 int dataPin = 11;
void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); }
void loop() { // count from 0 to 4 and display the number // on the LEDs for (int numberToDisplay = 0; numberToDisplay < 4; numberToDisplay++) { // take the latchPin low so // the LEDs don't change while you're sending in bits: digitalWrite(latchPin, LOW); // shift out the bits: shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay); //take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); // pause before next value: delay(500); } }
I have a question about the current draw from the arduino 5v pin. Is it true that i can pull around 450mA from that pin(Usb powered, arduino uno itself use around 50mA or something close to that, so that leaves me 450mA IF all the digital pins are turned low).
No problem, I just thought it was weird because I was sure I made the post . Anyway, my next project will be 5x5x5. I already ordered some shift register to experiment with and learn the basics of them , I probably going to use shift registers on my 3x3x3 cube first to make sure I understand the programming and the way the shift registers work.
Don't know how, but Arduino001 should be me (WonderTiger), Weird..... Thanks anyway for your positive reply ! (and thanks ofcourse for sharing your code as well )
Another video , multiplexed so only 1 layer is lit on any given time(im using array's and for loops to turn on the LEDs, easier to program/the code is shorter):
edit: this code has even less lines as the one that I showed 2 posts back .
Got my LED cube build today ! This code I made as a test:
I used for() loops as delay between the columns as well for making the led columns run at their full brightness.
Code:
int layer1 = 11; int layer2 = 12; int layer3 = 13; int led1 = 10; int led2 = 9; int led3 = 8; int led4 = 7; int led5 = 6; int led6 = 5; int led7 = 4; int led8 = 3; int led9 = 2; int r = 1;