Pages: 1 [2]   Go Down
Author Topic: how to drive 25 led with 5 pcs of 595 shift register?  (Read 1029 times)
0 Members and 1 Guest are viewing this topic.
Croatia
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


You can either slow it down or you can use buffers.

Both are very simple.


can you direct me how? with some link maybe?
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are using hardware spi, you can change the clock rate.

If you are using software spi, you can insert delays, like this:

Code:
#define spi_delay()  {NOP(); NOP(); NOP(); NOP(); NOP();} //insert your delay here. example uses 5 nop instructions

void myshiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
{
uint8_t i;

for (i = 0; i < 8; i++)  {
digitalWrite(clockPin, LOW);
                spi_delay(); //insert delay
if (bitOrder == LSBFIRST)
digitalWrite(dataPin, !!(val & (1 << i)));
else
digitalWrite(dataPin, !!(val & (1 << (7 - i))));

                spi_delay(); //insert delay
digitalWrite(clockPin, HIGH);
                spi_delay(); //insert delay
}
}[/core]

By changing the delay you use, you can slow down myshiftOut() as much as you want.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 439
Posts: 23782
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You guys are getting carried away on th clock rates.
You've got 25 LEDs a meter apart going down the length of a swimming pool, they pace a swimmer and don't get updated all that quick.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: 1 [2]   Go Up
Jump to: