Monday, March 26, 2012

The Cylon eye / Knight rider effect.

Using the same circuit arrangement as previously posted, we can turn our simple light meter into a Cylon eye! This shows the flexibility of the Arduino and how powerful software can be:

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