Hi ,
i want to do a display with 84 leds so i used a 74hc595 with an arduino Uno. However , i don't know how to manage the four 74hc595 to light up the led one by one and make them all blink. For this implementation ,i do first a modelisation on Proteus . i learn how one 74hc595 function but when i use the four 74hc595 i don't know how to shiftOut 4bytes to create sequence of byte for lighting up my 84 led one by one and after make them all blind.
I already thanking you for your help
i don't know how to shiftOut 4bytes
Lots of ways. I don't know how you are doing it now.
You can split the output pattern into 4 bytes and use shift out four times. Or use the idea below and shift the output pattern 8 places to the right before each shift out. Do not latch the data between these four shift outs, only latch at the very start and very end.
To handle 4 shift registers you need a variable type that is 4 bytes lone. The long unsigned int is such a variable type.
Hi ,thank you for answering.In fact,to light up the leds one by one i have to shift out 4 bytes.I try to used a special shiftOut algorithm to transmit 4bytes simultaneously that i read in another topic on the 16th message that you can see on the link below:
http://forum.arduino.cc/index.php?topic=157756.msg1966948#msg1966948
But my program don't work i don't know why.I might have done a bad modification to use it for 4 registers 74hc595
Waiting your answer.
There is nothing more useless than a screen dump of code, other than a Frtizing layout diagram.
Please post the code, and all the code, correctly.
Please read this:-
How to use this forum
sorry Here is my code:
const int verrou = 10;
//Broche connectée au SH_CP du 74HC595
const int horloge = 12;
//Broche connectée au DS du 74HC595
const int data = 11;
//The 4bytes i want to shift out
uint32_t myData=0b11001111000010101111111111111111;
void setup()
{
pinMode(verrou, OUTPUT);
pinMode(horloge, OUTPUT);
pinMode(data, OUTPUT);
}
void loop()
{
for (int i = 0; i < 32; i++)
{
digitalWrite(verrou, LOW);
shiftOut32(data, horloge, MSBFIRST,myData,32,100);
//myData=myData>>8;
//myData = myData | (0x00000001 << i);
digitalWrite(verrou, HIGH);
delay(500);
}
}
//This function might shift out 4bytes
void shiftOut32(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint32_t val, uint8_t count, uint8_t delayTime)
{
int i;
for (i = 0; i < count; ++i)
{
if (bitOrder == LSBFIRST)
digitalWrite(dataPin, !!(val & (1 << i)));
else
digitalWrite(dataPin, !!(val & (1 << ((count - 1) - i))));
digitalWrite(clockPin, HIGH);
delayMicroseconds(delayTime);
digitalWrite(clockPin, LOW);
delayMicroseconds(delayTime);
}
}
const int verrou = 10;
//Broche connectée au SH_CP du 74HC595
const int horloge = 12;
//Broche connectée au DS du 74HC595
const int data = 11;
//The 4bytes i want to shift out
byte myData[4] = {0b11001111, 0b00001010, 0b11111111, 0b11111111};
void setup()
{
pinMode(verrou, OUTPUT);
pinMode(horloge, OUTPUT);
pinMode(data, OUTPUT);
}
void loop()
{
digitalWrite(verrou, LOW);
for (int i = 0; i < 3; i++)
shiftOut(data, horloge, MSBFIRST, myData[i]);
digitalWrite(verrou, HIGH);
delay(500);
}
Simpler?