aschuma

Lasse :: Arduino :: Knight Rider

May 4th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. //Pin verbunden mit SH_CP des 74HC595
  2. int shiftPin = 8;
  3. //Pin verbunden mit ST_CP des 74HC595
  4. int storePin = 9;
  5. //Pin verbunden mit DS des 74HC595
  6. int dataPin = 10;
  7.  
  8. int counter = 1;
  9. int counter2 = 8 ;
  10.  
  11. int poti = 0;
  12. int mintime = 10;
  13.  
  14.  
  15. void setup() {
  16.  // Pins 8,9,10 OUT
  17.  pinMode(storePin, OUTPUT);
  18.  pinMode(shiftPin, OUTPUT);
  19.  pinMode(dataPin, OUTPUT);
  20. }
  21.  
  22.  
  23. void loop () {
  24.  
  25.  digitalWrite(storePin, LOW);
  26.  shiftOut(dataPin, shiftPin, MSBFIRST, counter + counter2);
  27.  digitalWrite(storePin, HIGH);
  28.  
  29.  // Potentiometer zwischen 0 und 1023)
  30.  poti = analogRead(0);
  31.  delay(mintime+poti/4);
  32.  
  33.  counter = counter * 2;
  34.  if (counter > 255) {
  35.    counter = 1;
  36.  }
  37.  
  38.  counter2 = counter2 * 2;
  39.  if (counter2 > 255) {
  40.    counter2 = 1;
  41.  }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment