Go Down

Topic: trying to control 37leds with 5x 74HC595 (Read 2 times) previous topic - next topic

Nick Gammon

Quote
but the unsigned long long got 64 bits if you use highbit and lowbit on that i don't know what you will get but it isn't the upers 32bits and the other 32 bits that i would need to split up again untill its 8bits / piece


Sorry, that's just not making sense.

Nick Gammon

Quote
Re: trying to control 37leds with 5x 74HC595


All you need to do is set up the 5 x 8 bits that you want to display in 5 bytes. Then:

Code: [Select]

SPI.transfer (a);
SPI.transfer (b);
SPI.transfer (c);
SPI.transfer (d);
SPI.transfer (e);


That's it. No longs, long longs, or anything.

Grumpy_Mike

Quote
i hope you understand me

No I don't.

Quote
and that are the things i only can use for this project.

Sounds like a school assignment then. If so it is designed to make you learn stuff and this is what you are refusing to do. So far in terms of learning you should get an F.

Quote
because the shift register works with an 8bit system so you need to send 5times 8bits you can't send them in one piece

That is just rubbish.

Quote
and then shift them on a randomspeed from 0->36-0->36-->.

In reply #8 I gave you code to do this. But you just ignored it.

Quote
i am on the limit rigth know..

No you are not at the limit you are way beyond knowledge and into fairy land.
Why bother asking a question if you just ignore the answer.
If you don't understand the answer then ask about what you don't understand.
There are lots of ways to tackle your problem. None of them are as hard as the solution your misunderstandings are forcing to to try and implement.

kjellebormans

#23
Mar 19, 2012, 11:30 am Last Edit: Mar 19, 2012, 11:32 am by kjellebormans Reason: 1
i thank you all for trying to help me out :)
but know i figured it out with some help offcourse :)

tnx to http://bildr.org/2011/02/74hc595/#

Code: [Select]
int SER_Pin = 8;   //pin 14 on the 75HC595
int RCLK_Pin = 9;  //pin 12 on the 75HC595
int SRCLK_Pin = 10; //pin 11 on the 75HC595

//How many of the shift registers - change this
#define number_of_74hc595s 5

//do not touch
#define numOfRegisterPins number_of_74hc595s * 8

boolean registers[numOfRegisterPins];

int Randomwaarde;
int del = 5 ;
void setup(){
 pinMode(SER_Pin, OUTPUT);
 pinMode(RCLK_Pin, OUTPUT);
 pinMode(SRCLK_Pin, OUTPUT);

 //reset all register pins
 clearRegisters();
 writeRegisters();

 randomSeed(analogRead(3));
 Randomwaarde = random(190, 210);
 Serial.println(Randomwaarde);
}              

//set all register pins to LOW
void clearRegisters(){
 for(int i = numOfRegisterPins - 1; i >=  0; i--){
   registers[i] = LOW;
 }
}

//Set and display registers
//Only call AFTER all values are set how you would like (slow otherwise)
void writeRegisters(){

 digitalWrite(RCLK_Pin, LOW);

 for(int i = numOfRegisterPins - 1; i >=  0; i--){
   digitalWrite(SRCLK_Pin, LOW);

   int val = registers[i];

   digitalWrite(SER_Pin, val);
   digitalWrite(SRCLK_Pin, HIGH);

 }
 digitalWrite(RCLK_Pin, HIGH);

}

//set an individual pin HIGH or LOW
void setRegisterPin(int index, int value){
 registers[index] = value;
}

void loop(){


 for (int x=0; x<=36; x++)
 {
   if (del <= Randomwaarde)
   {
     setRegisterPin(x, HIGH);
     writeRegisters();
     delay(del);
     setRegisterPin(x, LOW);
     writeRegisters();
     del = del +1;
   }
   else
   {
     setRegisterPin(x, HIGH);
     writeRegisters();
     delay(10000);
     setRegisterPin(x, LOW);
     writeRegisters();
     del = 5;

   }

 }
}



Go Up