Pages: [1]   Go Down
Author Topic: shift register  (Read 495 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

bonjour ,
je suis nouveau donc je voulais savoir si quelqu'un pouvait m'aider car je n'arrive pas à très bien comprendre le fonctionnement du shift register , la j'ai un programme ou j'ai pas compris pourquoi il appelle
latchPin ou encore dataPin et ClockPin ? et shiftOut il sert à quoi
merci de bien vouloir me renseigner
merci :-) smiley-wink

//Pin connected to Pin 12 of 74HC595 (Latch)
int latchPin = 8;
//Pin connected to Pin 11 of 74HC595 (Clock)
int clockPin = 12;
//Pin connected to Pin 14 of 74HC595 (Data)
int dataPin = 11;
void setup() {
//set pins to output
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
//count from 0 to 255
for (int i = 0; i < 256; i++) {
//set latchPin low to allow data flow
digitalWrite(latchPin, LOW);
shiftOut(i);
//set latchPin to high to lock and send data
digitalWrite(latchPin, HIGH);
delay(500);
}
}
void shiftOut(byte dataOut) {
// Shift out 8 bits LSB first,
// on rising edge of clock
boolean pinState;
//clear shift register ready for
sending data
digitalWrite(dataPin, LOW);
digitalWrite(clockPin, LOW);
// for each bit in dataOut send out
a bit
for (int i=0; i<=7; i++) {
//set clockPin to LOW prior to sending bit
digitalWrite(clockPin, LOW);
// if the value of DataOut and (logical
AND) a bitmask
// are true, set pinState to 1 (HIGH)
if ( dataOut & (1<<i) ) {
pinState = HIGH;
}
else {!
pinState = LOW;
}
//sets dataPin to HIGH or LOW depending on
pinState
digitalWrite(dataPin, pinState);
//send bit out on rising edge of clock
digitalWrite(clockPin, HIGH);
}
//stop shifting out data
digitalWrite(clockPin, LOW);
}
Logged

$300:20 58 FC 60
Offline Offline
Newbie
*
Karma: 1
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Tu peux déjà commencer à voir ca : http://www.arduino.cc/en/Tutorial/ShiftOut  smiley
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

merci bcp de ta réponse rapide , mais je ne comprends pas pourquoi il faut utiliser le calcul binaire ???????????? :-[
Logged

Pages: [1]   Go Up
Jump to: