Go Down

Topic: how to drive 25 led with 5 pcs of 595 shift register? (Read 1 time) previous topic - next topic

flega



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

Both are very simple.



can you direct me how? with some link maybe?

dhenry

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: [Select]

#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.

CrossRoads

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.
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.

Go Up