Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 24, 2022 08:05 am GMT

Getting started with Arduino ( build a knight rider LED simulation)

Hi everyone, today I thought of making a complete beginner guide to the people who are new to ARDUINO. In this post I am going to give a detailed description of making a knight rider LED simulation circuit (beginner project) from scratch. For this project I am using an Arduino UNO board.

Well, Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing. Learn more about Arduino and boards visit arduino.cc

As I mentioned earlier I am using an Arduino UNO board for this project. You can buy it online or you can simply simulate the whole project by visiting tinkercad.

Here is an detailed image of the board

Image description
And you need to install the Arduino IDE software to start programing. So download and install it as well.

So now let's get started with the project

Connecting the components together

For this project we need following components

  • Arduino UNO x1

  • LED x6

  • wires

  • project board x1

connect the components together as shown as below

Image description

Writing the program

Now that the components are wired together, connect your board to the pc and open Arduino IDE. First make sure that the correct port is selected from the tools.

Image description

The Arduino program contains two main parts: setup () and loop (). The name of the functions implies their purpose and activity: setup () sets up the Arduino hardware, such as specifying which I/O lines is planned to use, and whether they are inputs or outputs. The loop () function is repeated endlessly when the Arduino runs.

void setup() {  // put your setup code here, to run once:}void loop() {  // put your main code here, to run repeatedly:}

So at first we need to declare our output pins. As the 6 LEDs are connected to the 2-7 digital pins, Let's make them as output using pinMode(). This part goes to the setup() part.

void setup() {  pinMode(2,OUTPUT);  pinMode(3,OUTPUT);  pinMode(4,OUTPUT);  pinMode(5,OUTPUT);  pinMode(6,OUTPUT);  pinMode(7,OUTPUT);}

Note :- each line should end with a ";"

To simply this part we can use a For loop as below

{  for (int i = 2; i <= 7; i++) {    pinMode(i , OUTPUT);  }

Now let's think about the output we need. The LEDs should blink like the Knight Rider Car light. Left to right, right to left, on repeat. To accomplish that we need to blink each LED one after other as a line.


Original Link: https://dev.to/chamodperera/getting-started-with-arduino-build-a-knight-rider-led-simulation-1j50

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To