int counter = 0;
int direction = true;
void setup() {
PORTD = B00000000;
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
}
void loop() {
if(direction) {
counter++;
if(counter == 7) {
direction = false;
}
}
else {
counter--;
if(counter == 0) {
direction = true;
}
}
PORTD = 1 << counter;
PORTD = PORTD | 1 << counter + 1;
delay(80);
}
The effect could probably enhanced by adding capacitors between the base and ground on each transistor, causing the adjacent LEDs to fade in/out.
No comments:
Post a Comment