Schemat połączeń:
Gotowy efekt:
Program do wgrania:
/* Knight Rider elektrodynka
* --------------
* (cleft) 2005 K3, Malmo University
* @author: David Cuartielles
* @hardware: David Cuartielles, Aaron Hallborg
*/
int pinArray[] = {2, 3, 4, 5, 6, 7, 8}; // piny diod LED
int count = 0;
int timer = 13; // prędkość efektu
void setup(){
for (count=0;count<7;count++) { // ilość diod
pinMode(pinArray[count], OUTPUT);
}
}
void loop() {
for (count=0;count<7;count++) { // ilość diod
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count + 1], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer*2);
}
for (count=5;count>0;count--) {
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count - 1], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer*2);
}
}
Gotowiec do pobrania:
https://drive.google.com/open?id=1-M7JFuHrDN-naC8WGAQAincuM2gT5mRe