Hello Knight Rider

This is my Arduino “Hello World” project, inspired by my TV set’s please wait indicator (that reminds me of Knight Rider’s K.I.T.T car).

The two potentiometers on the video were used to adjust speed and maximum brightness of the LEDs (variables maxBrightness and stepDelay). In the sketch below they are still fixed.

 

 

 

Thanks to the Crayon WordPress plugin, posted Arduino sketches will now look (almost) like they do in the Arduino IDE. The following sketch will produce the above variant of the ‘Larson scanner’, better known as the KITT scanner from the TV series Knight Rider.

Pin numbers are for the Arduino Uno (must be PWM pins). Note that by using a two-dimensional ledPins array and toggling its first index, there’s no need to have separate loops for both directions (outer for loop). The code for fading can be kept simple by introducing virtual LEDs (inner for loop).