0

Tutorials with Arduino: The Knight Rider

A very dumb and simple, but really good looking example of the Arduino UNO and LEDS. The effect of the Knight Rider Car.

The idea with this example is to learn how to work with arrays on the code. (see the code below)

Here is the project working on video:

Part List:

  • 1 x Arduino UNO
  • 7 x Red Leds
  • 7 x 220ohm resist.

The connections are very simple:

Attach  each led with it´s resistor to a digital output (from 3 to 9). The rest is in the code.

The Source Code:

/* Knight Rider 3
 * --------------
 *
 * This example concentrates on making the visuals fluid.
 *
 *
 * (cleft) 2005 K3, Malmo University
 * @author: David Cuartielles
 * @hardware: David Cuartielles, Aaron Hallborg
 */

int pinArray[] = { 3, 4, 5, 6, 7, 8, 9};
int count = 0;
int timer = 10;

void setup(){
  for (count=0;count<8;count++) {
    pinMode(pinArray[count], OUTPUT);
  }
}

void loop() {
  for (count=0;count<6;count++) {
   digitalWrite(pinArray[count], HIGH);
   delay(timer);
   digitalWrite(pinArray[count + 1], HIGH);
   delay(timer);
   digitalWrite(pinArray[count], LOW);
   delay(timer*2);
  }
  for (count=6;count>0;count--) {
   digitalWrite(pinArray[count], HIGH);
   delay(timer);
   digitalWrite(pinArray[count - 1], HIGH);
   delay(timer);
   digitalWrite(pinArray[count], LOW);
   delay(timer*2);
  }
}

Related Posts

  • Here is my third proyect, it´s an level meter with led via the Headphone out of my mixing console with the Arduino UNO. Here is the device working on video (updated video in english using the Iphone Photostudio for arduino stand): Very simple, you read the voltage from the headphone output…
    Tags: the, int, count, for, arduino, led, tutorial, diy
  • This is a very simple proyect too. We are measuring the ambient temperature with a Thermistor (4,7k) and showing the results by an RGB Led. We are assuming the cool temperature is Blue and the hot is Red. You can see it working in this video: http://www.youtube.com/watch?v=uouKAKhgowQ The part list…
    Tags: the, led, tutorial, diy, arduino
  • Controlling Leds by the Apple Remote (video updated using the Iphone Photostudio for Arduino Stand) http://www.youtube.com/watch?v=vjnOvdJrHMo The idea originated because i´m learning a lot on Led driven home applications for lighting, and the first project i´m doing is led lighting for the kitchen (indirect). The commercial systems are very expensive,…
    Tags: the, led, tutorial, diy, arduino