We also call this example "Knight Rider" in memory of a TV-series from the 80's where David Hasselhoff had an AI machine named KITT driving his Pontiac. The car had been augmented with plenty of LEDs in all possible sizes performing flashy effects. In particular, it had a display that scanned back and forth across a line, as shown in this exciting fight between KITT and KARR. This example duplicates the KITT display.
Step 1: What You Need?
1 x Arduino Board ( Arduino UNO R3 used in this tutorial.)
6 x LEDs (RED)
6 x 220 Ohm Resistors
1 x Mini Breadboard
1 x USB Type-B Cable
Male-to-Male Jumper Wires
Connect six LEDs, with 220 ohm resistors in series, to digital pins 2-7 on your board.
1. Select the Arduino board type: Select Tools >> Board >> Select your correct Arduino board used.
6 x LEDs (RED)
6 x 220 Ohm Resistors
1 x Mini Breadboard
1 x USB Type-B Cable
Male-to-Male Jumper Wires
Optional
Don't have components? Don't worry. Just click the component's name. Step 2: Build Your Circuit.
Step 3: Upload The Code.
2. Find the port number by accessing device manager on Windows. See the section Port (COM&LPT) and look for an open port named "Arduino Uno (COMxx)". If you are using a different board, you will find a name accordingly. What matters is the xx in COMxx part. In my case, it's COM3. So my port number is 3.
Select the right port: Tools >> Port >> Select the port number.
3. You can find this code in the example of Arduino IDE.
Select File >> Examples >> 05. Control >> ForLoopIteration
Click press the "upload" button (see the button with right arrow mark).
The code below begins by utilizing a for() loop to assign digital pins 2-7 as outputs for the 6 LEDs used.
In the main loop of the code, two for() loops are used to loop incrementally, stepping through the LEDs, one by one, from pin 2 to pin seven. Once pin 7 is lit, the process reverses, stepping back down through each LED.
The code below begins by utilizing a for() loop to assign digital pins 2-7 as outputs for the 6 LEDs used.
In the main loop of the code, two for() loops are used to loop incrementally, stepping through the LEDs, one by one, from pin 2 to pin seven. Once pin 7 is lit, the process reverses, stepping back down through each LED.
Download:
0 comments:
Post a Comment