Pages: [1] 2   Go Down
Author Topic: Buddys LED project-part 2  (Read 1823 times)
0 Members and 1 Guest are viewing this topic.
Virginia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Professional Botter
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I searched around the house as wel as tried a couple of smart phones but NONE of the videos were even close to being clear to see my board and the effects.  Rats!

Using this page:  http://arduino.cc/en/Tutorial/ShiftOut

I successfully created the project using my Arduino Uno.  Looks great for a noob.

Now to expand upon this project I would like to add a third set of 8 LEDs and maybe more.  Yes, it will be a REALLY long chasing sequence (at least in one direction only).

I added a 3rd shift register, got the LEDs hooked up and other parts and then I looked at the code.  That is when it hit me that the code was not as easy to modify.  Daisy chaining the shift registers was easy enough.

Am I being too simplistic with the components or is the sketch code still on the easy side.

Like I said, I am using the code from that link above.  When I did hook up my Arduino Uno and load the sketch the chase did start but the first & third shift register LEDs blinked away in parallel just as I thought they would.

Thanks for any help. 

Buddy
Logged

Canberra Australia
Offline Offline
God Member
*****
Karma: 11
Posts: 518
Hardcore Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Buddy.
 I did mention it on your other thread Buddys LED project but if I were you I would ditch the Arduino Shiftout info and look at these three links. They helped me to connect more than one shift register and after looking at the code and applying my gi-normous brainpower (LOL)  I saw how to turn on the LED,s in the order that I wanted to. I am at work now (hey boss I'm on a lunch break, ok….) but later I will put a bit of info together and post it for you if you are still having trouble,
 Pedro

http://tronixstuff.wordpress.com/2010/04/30/getting-started-with-arduino-chapter-four/

http://www.gammon.com.au/forum/?id=11518

http://bildr.org/2011/02/74hc595/

p.s. - In the meantime try this code for two shift registers

Code:
 
int dataPin = 2;        //Define which pins will be used for the Shift Register control
int latchPin = 3;
int clockPin = 4;

int seq1[14] = {1,2,4,8,16,32,64,128,64,32,16,8,4,2};  //The array for storing the
// byte #1 value
int seq2[14] = {128,64,32,16,8,4,2,1,2,4,8,16,32,64};  //The array for storing the
// byte #2 value

void setup()
{
    pinMode(dataPin, OUTPUT);       //Configure each IO Pin
    pinMode(latchPin, OUTPUT);
    pinMode(clockPin, OUTPUT);
}

void loop()
{
    for (int x = 0; x < 14; x++)         //Array Index
    {
        digitalWrite(latchPin, LOW);            //Pull latch LOW to start sending data
        shiftOut(dataPin, clockPin, MSBFIRST, seq1[x]);         //Send the data byte 1
        shiftOut(dataPin, clockPin, MSBFIRST, seq2[x]);         //Send the data byte 2
        digitalWrite(latchPin, HIGH);           //Pull latch HIGH to stop sending data
        delay(75);
    }
}

« Last Edit: September 20, 2012, 01:28:24 am by Pedro147 » Logged


Virginia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Professional Botter
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Pedro.

I am re-studying those now.  When I get home I will try your code out.

I get the array side...so I am curious as to the visual effect that this will create especially from the seq2 array.

From seq1 I can see how the binary movement will turn on LEDs 0-7 but after 128 and doing 64 againappears that it would turn on the #6 LED on the 1st shift register.  But then again I could be over analyzing this.  Hmmmm...can't wait to get home and see this.

Thanks again for reeling me back in!  LOL
Logged

Virginia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Professional Botter
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think I have a way to get my images made now so I will redo the pics later this evening.

Here is the video I made last night.  Its not as bad as I thought but you will see what I am doing.



Buddy
Logged

Virginia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Professional Botter
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I ran your code Pedro and I now see what it does.  Neat.  Now I will play with that and see if I can tweak it to a third shift register.

More to come...
Logged

Canberra Australia
Offline Offline
God Member
*****
Karma: 11
Posts: 518
Hardcore Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Buddy,  from memory smiley-cool just add a third shift register data out of SR 2 to data in of SR 3 and make another array (int seq3)
Logged


Virginia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Professional Botter
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Pedro,

I did that as well separating the FOR loops but the desired effect is still not there.



Here is my current sketch:
Code:
int dataPin = 11;        //Define which pins will be used for the Shift Register control
int latchPin = 8;
int clockPin = 12;

int seq1[8] = {1,2,4,8,16,32,64,128};  //The array for storing the
// byte #1 value
int seq2[8] = {1,2,4,8,16,32,64,128};  //The array for storing the
// byte #2 value
int seq3[8] = {1,2,4,8,16,32,64,128};  //The array for storing the
// byte #3 value

void setup()
{
    pinMode(dataPin, OUTPUT);       //Configure each IO Pin
    pinMode(latchPin, OUTPUT);
    pinMode(clockPin, OUTPUT);
}

void loop()
{
    for (int x = 0; x < 8; x++)         //Array Index
    {
        digitalWrite(latchPin, LOW);            //Pull latch LOW to start sending data
        shiftOut(dataPin, clockPin, MSBFIRST, seq1[x]);         //Send the data byte 1
        digitalWrite(latchPin, HIGH);           //Pull latch HIGH to stop sending data
        delay(75);
    }
    for (int x = 0; x < 8; x++)         //Array Index
    {
        digitalWrite(latchPin, LOW);            //Pull latch LOW to start sending data
        shiftOut(dataPin, clockPin, MSBFIRST, seq2[x]);         //Send the data byte 2
        digitalWrite(latchPin, HIGH);           //Pull latch HIGH to stop sending data
        delay(75);
    }
    for (int x = 0; x < 8; x++)         //Array Index
    {
        digitalWrite(latchPin, LOW);            //Pull latch LOW to start sending data
        shiftOut(dataPin, clockPin, MSBFIRST, seq3[x]);         //Send the data byte 3
        digitalWrite(latchPin, HIGH);           //Pull latch HIGH to stop sending data
        delay(75);
    }
}

I realize that this are binary numbers sequencing through the circuit but it would be great to be able to switch to the shift register to control the 8 LEDs for the effect.

I did read one of the web pages you suggested above and there was some coding that might be able to accomplish that feat.

I think I am getting closer so thanks for the help!

Buddy
Logged

Canberra Australia
Offline Offline
God Member
*****
Karma: 11
Posts: 518
Hardcore Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As I mentioned Buddy my coding expertise is next to zero I just play around with the code that I find and try and work out how to use it to do what I want (not lazy just coding challanged  smiley-cool ) When you say "but the desired effect is still not there" what is your desired effect exactly. From memory that code I posted should do what I call "the alternate sweep" where one 8 LED row flashes on and off one LED after the other from LED 1 to LED 8 and back again ad infinitum, and the other does the same thing from LED 16 to LED 9 (if that makes sense)
p.s. You aren't still using that 1 mf  capacitor on the latch (STCP) from that Shiftout page are you? (just a thought as I have seen many people on this forum condemn that cap)                                    
« Last Edit: September 21, 2012, 05:41:11 pm by Pedro147 » Logged


Virginia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Professional Botter
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

LOL  The video has that cap but it has been removed.  Good eye!

My desired effect is this.  All of my LEDs will be in a single row like the video below but I will start on one end and it should cycle all the way to the other end.  Only one LED on at a time.

   

I am hoping to have a few more shift register for a longer line of LEDs.

I have a specific purpose for this.

Buddy
Logged

Virginia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Professional Botter
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks to Pedro I have some code that I am able to tweak to achieve the desired effect.



I am using four 74HC595 shift registers and 32 Super Brite LEDs.  I could not figure out how to use just one Data and Latch pin so I ended up using four of each.  I also used a single clock pin as well as the ground and power from my Arduido.

Some LEDs are brighter than others this is because of my resistors.  I will be changing those out and making them more consistent.  I also took off the CAP that the original schematic had and I like what I see.

I believe there is an easier way to accomplish this with less Pin from my Arduino so hopefully a more experienced person will chime in.

All in all I am learning and enjoying this.

Back to playing now...

Buddy
Logged

Canberra Australia
Offline Offline
God Member
*****
Karma: 11
Posts: 518
Hardcore Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Buddy ,

I was trolling thru my LED videos this morning and thought you might be interested in one of how that code I pointed you to looked the way I connected it up,

Pedro




(hey I know it's not Rocket Science but I'm learnin' too)  smiley-cool  smiley-cool
Logged


Virginia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Professional Botter
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah I saw that.  I sent you a PM so you coud look at something.

Buddy
Logged

Virginia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Professional Botter
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have some better resistors on orders for my project so in the mean time here is another question for those more experienced.

I have read about putting code from an Arduino on to AT Tiny ICs and I would like to do that as well so I do not tie up my Arduino.  I am planning on cloning my project so it would be better for me to have a way to "Shrinkify" (using Make Mags DIY project).

In my project I am using 8 outputs plus the clock pin, as well as the power and ground.

Will a AT Tiny IC do the job for me and which one should I use.

Thanks!

Buddy
Logged

Virginia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Professional Botter
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bump
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 152
Posts: 5757
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this:

Code:
void loop()
{
    for (int x = 0; x < 8; x++)         //Array Index
    {
        digitalWrite(latchPin, LOW);            //Pull latch LOW to start sending data
        shiftOut(dataPin, clockPin, MSBFIRST, seq1[x]);         //Send the data byte 1
        shiftOut(dataPin, clockPin, MSBFIRST,0);
        shiftOut(dataPin, clockPin, MSBFIRST,0);
        digitalWrite(latchPin, HIGH);           //Pull latch HIGH to stop sending data
        delay(75);
    }
    for (int x = 0; x < 8; x++)         //Array Index
    {
        digitalWrite(latchPin, LOW);            //Pull latch LOW to start sending data
        shiftOut(dataPin, clockPin, MSBFIRST,0);
        shiftOut(dataPin, clockPin, MSBFIRST, seq2[x]);         //Send the data byte 2
        shiftOut(dataPin, clockPin, MSBFIRST,0);
        digitalWrite(latchPin, HIGH);           //Pull latch HIGH to stop sending data
        delay(75);
    }
    for (int x = 0; x < 8; x++)         //Array Index
    {
        digitalWrite(latchPin, LOW);            //Pull latch LOW to start sending data
        shiftOut(dataPin, clockPin, MSBFIRST,0);
        shiftOut(dataPin, clockPin, MSBFIRST,0);
        shiftOut(dataPin, clockPin, MSBFIRST, seq3[x]);         //Send the data byte 3
        digitalWrite(latchPin, HIGH);           //Pull latch HIGH to stop sending data
        delay(75);
    }
}

Remember, with three chips you have to send three bytes of data every time, not one.
« Last Edit: September 28, 2012, 02:32:23 pm by fungus » Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Pages: [1] 2   Go Up
Jump to: