Thursday, December 1, 2022
Home Arduino Starting Arduino Programming with Digital Write and Blink LED

Starting Arduino Programming with Digital Write and Blink LED

This is the second article in our arduino article set.Today we will see what are the components of arduino board and what are their functions.

Today we will see how to connect an Arduino board to a computer, how to program it, and how to make our first small circuit.

How to connect an Arduino board to a computer.

  (1) We need to download the Arduino software first. That is where we write the program and the program that we upload to the Arduino board.

i) Search Arduino download from the Google.

ii) Then go to the link called Download the Arduino Software and download Windows/ Mac OS / Linux that relevant to your PC from that site.

iii) Open the Arduino ID after downloading.

arduino IDE

iv) Then when it opens, we see an empty window.

(2) Now we need to connect the Arduino board to the computer with a USB cable.

  (3) Once the Arduino board is connected to the computer, go to the Arduino ID tools on the PC, go to the port and select the CQM21 port. Most of the time when we connect the Arduino board, the Arduino board is auto detected.

   Or go to port and see if there is a comport in the list. It will be an Arduino.

   Or if it does not show anything, updating the USB drives and try again.

    Otherwise, open the device manager and right click on the unknown devices below it to update. Then the Arduino Uno board connects to the computer and shows the port in the Arduino ID.

(4) Then go to the tools and select the board that we have connected from that list. What we are doing now is the Arduino Uno board, we have selected it.

   (5) After that, press the upload button to see if the program connects the Arduino board with the computer using a method called AVRISP. Then the empty sketch will be uploaded to our Arduino board.

Then it says done uploading. This means that the computer is exactly connected to the Arduino board.

How to program Arduino from Arduino language.

Arduino libraries is the programming language to program this. (similar to C++ , C, JAVA)

Next, we will look at how to code a program.

There are two methods. Those are Void setup and Void loop method.  We can see a comment begins with a ‘//’ (forward slash) of this. That tells us what happens with these two methods. If you want, you can remove or change this comment.

The method called setup, execute the program that we code, and after uploading it to the Arduino board. Then it will run once. Then other things happen in this setup method and it goes beyond here.         

In void loop method, after we coding a code in this, it will run continuously like a loop.  Inside the loop we code the main program.

How to code a simple program

(1) Inside the void setup, first set the pin mode to the 13th pin as an output.

(2) The digital Write in the loop tells the 13th pin to delay 1000 milliseconds (1000 ms = 1s) as a high (on/1) digital signal.

(3) Then the opposite of the previous one, digital Write 13th pin to delay 1000 milliseconds as a low (off/0) digital signal.

(4) After the program is written you can check if there are any errors in the program by verifying it. (not compulsory)

  Otherwise, the program can be coded and uploaded to the Arduino board. When uploading, you can see those two buttons with RXTX on the board are blinking.

The light connected to the 13th pin is dimmed for a second and turned off for a second. That way this loop will run continuously.

Let’s connect a LED Light and a 330ohm Resistor to the Arduino board and connect it to the computer.

(1) Remove the Arduino board from the PC and put the resistor on the (-) cathode (small pin) pin of the light and connect it.

(2) Connect the (+) Anode (long pin) pin to the 13th pin. And connect the other edge of the resistor to the ground pin.

(3) Then again connect the USB cable that gives power and connects the Arduino board to the computer and the LED light blinks as before.



Leave a reply

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments

Kaushi ki on Arduino IDE Lesson 02
Osiru Domnic on Identify Arduino Component