Yep!
La solution la plus simple est de définir dans ta boucle for, une valeur de i < 60 et mettre les shiftout en série tout simplement entre les ST_CP (latch)
digitalWrite(ST_CP, LOW);
shiftOut(DS, SH_CP, MSBFIRST, B00010001); // 1er 595
shiftOut(DS, SH_CP, MSBFIRST, B11101110); // 2eme 595
digitalWrite(ST_CP, HIGH);
delay(200);
Si l'utilisation des registres ne te fais pas trop peur, un truc dans le genre devrait marcher :
#include <avr/io.h>
#include <util/delay.h>
#define number_of_74hc595s 1 //How many of the shift registers are there daisey chained?
void setup() {
}
void loop(){
PORTB = 0x00;
/*
char counter = 0;
while(1){
counter++; // Counter used for displaying a number in binary via the shift register
shift(PB4, PB0, PB3, counter); // PB1 = SERCLK PB2 = RCLK PB3 = SER
_delay_ms(500);
shift(PB4, PB0, PB3, 0x00); // Set all pins to off
_delay_ms(500);
}
*/
shift(PB4, PB0, PB3, B11100000);
delay(500);
shift(PB4, PB0, PB3, 0x00);
delay(500);
}
void shift(int SRCLK_Pin, int RCLK_Pin, int SER_Pin, unsigned long data){
PORTB &= ~(1 << RCLK_Pin); // Set the register-clock pin low
for (int i = 0; i < (8 * number_of_74hc595s); i++){ // Now we are entering the loop to shift out 8+ bits
PORTB &= ~(1 << SRCLK_Pin); // Set the serial-clock pin low
PORTB |= (((data&(0x01<<i))>>i) << SER_Pin ); // Go through each bit of data and output it
PORTB |= (1 << SRCLK_Pin); // Set the serial-clock pin high
PORTB &= ~(((data&(0x01<<i))>>i) << SER_Pin ); // Set the datapin low again
}
PORTB |= (1 << RCLK_Pin); // Set the register-clock pin high to update the output of the shift-register
}
Comme j'avais qu'un seul chip sous la main, je n'ai pas pû tester plus avant.
Faut vérifier l'ordre des bits, je crois qu'ils sont inversés dans ce dernier code, B00000001 signifie que l'on active le dernier bit...
@+
Zoroastre.