Go Down

Topic: EFFET TRANSITION DOUCE AVEC SHIFT REGISTER (Read 731 times) previous topic - next topic


kl

bonjour ,
Je voudrais savoir comment on peur réaliser un effet de transition douce avec un shift registrer j'ai déjà le programme du shift register qui commande les 8 leds mais je ne sais pas comment on passe du digital à l'analogique ou vice versa voici le rpemeir programme :
// Project 15
//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() {
// turn off the output so the pins don't light up
 // while you're shifting bits:



digitalWrite(latchPin, LOW);

 // shift the bits out:  0B10001000 sets pins 3 and 7
 shiftOut(dataPin, clockPin, MSBFIRST, B00000001);

   // turn on the output so the LEDs can light up:
 digitalWrite(latchPin, HIGH);
delay (500);


 digitalWrite(latchPin, LOW);

 // shift the bits out:  0B10001000 sets pins 3 and 7
 shiftOut(dataPin, clockPin, MSBFIRST, B00000010);

   // turn on the output so the LEDs can light up:
 digitalWrite(latchPin, HIGH);
delay (500);


digitalWrite(latchPin, LOW);

 // shift the bits out:  0B10001000 sets pins 3 and 7
 shiftOut(dataPin, clockPin, MSBFIRST, B00000100);

   // turn on the output so the LEDs can light up:
 digitalWrite(latchPin, HIGH);
delay (500);
digitalWrite(latchPin, LOW);

 // shift the bits out:  0B10001000 sets pins 3 and 7
 shiftOut(dataPin, clockPin, MSBFIRST, B00001000);

   // turn on the output so the LEDs can light up:
 digitalWrite(latchPin, HIGH);
delay (500);
digitalWrite(latchPin, LOW);

 // shift the bits out:  0B10001000 sets pins 3 and 7
 shiftOut(dataPin, clockPin, MSBFIRST, B00010000);

   // turn on the output so the LEDs can light up:
 digitalWrite(latchPin, HIGH);
delay (500);

digitalWrite(latchPin, LOW);

 // shift the bits out:  0B10001000 sets pins 3 and 7
 shiftOut(dataPin, clockPin, MSBFIRST, B00100000);

   // turn on the output so the LEDs can light up:
 digitalWrite(latchPin, HIGH);
delay (500);

digitalWrite(latchPin, LOW);

 // shift the bits out:  0B10001000 sets pins 3 and 7
 shiftOut(dataPin, clockPin, MSBFIRST, B01000000);

   // turn on the output so the LEDs can light up:
 digitalWrite(latchPin, HIGH);
delay (500);

digitalWrite(latchPin, LOW);

 // shift the bits out:  0B10001000 sets pins 3 and 7
 shiftOut(dataPin, clockPin, MSBFIRST, B10000000);

   // turn on the output so the LEDs can light up:
 digitalWrite(latchPin, HIGH);
delay (500);
digitalWrite(latchPin, LOW);

}

et le second progrmame pour faire les variations de lumière  mais je ne sais pas complier les deux programmes ensemble pour qu'ils fassent touts les actions possibles
merci de m'aider   :'(

kl

int ledPin = 11;
float sinVal;
int ledVal;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
for (int x=0; x<180; x++) {
// convert degrees to radians
// then obtain sin value
sinVal = (sin(x*(3.1412/180)));
ledVal = int(sinVal*255);
analogWrite(ledPin, ledVal);
delay(25);
}
} :'(

kl

est ce que quelqu'un peut m'aider car je n'y arrive pas  :'(

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy