Create your first project!
Welcome to this post!
In this post I will show to make a simple project using Arduino
Before you start please download Arduino IDE app-
Windows - https://www.microsoft.com/en-in/p/arduino-ide/9nblggh4rsd8
Picture from Microsoft store
Apple and Linux- Software | Arduino
Scroll down to see this - Click on the Mac OS X option. For Linux computer click on the Linux option
After installing the app, open it and you will see a screen like this-How Arduino IDE will look like after opening
Here are the terms we are going to use in the programming -
void setup()
void loop()
delay(number)
digitalWrite(variable, text)
int led = number
pinMode (variable, text)
Now, before we begin I will tell you the use of these terms:
- 'void setup()' is used when you want to run a set of commands only once. It also is used for preparing your program, like if you want your LED to be as a output or input you can use 'pinMode( variable, OUTPUT/INPUT)' to define if your LED is output or input.
- 'void loop()' is used when you want to run a set of commands forever.
- 'delay(number)' is used when you want to give a gap of a few seconds in between the code. The number in the brackets of the delay is measured in milliseconds, so for 1 second you will have to type 'delay(1000)'.
- 'digitalWrite(variable, text)' is used when you want to turn on or off your LED.
- 'int' is used when you want to declare a variable. To add a value to the varaible you have to type this - 'int led = 13', the number after the equals sign can be anything.
'//' is used when you want to give a one line comment. '/* and */' are used when you want to give a paragraph comment.
Let's begin!
Follow the steps below:
You will need:
Arduino UNO board (x1, you can use any Arduino board)
Male to male wires(x2)
LED(x1)
Resistor(x1)
Arduino UNO power cable(x1)
Breadboard(x1, any size)
Steps:
1) Place the LED on the breadboard.
2)Connect a Male to male wire to the anode of the LED and connect the opposite side of the wire to the digital pin 13 on the Arduino UNO Board.
3)Connect a resistor to the cathode of the LED. Connect the opposite end of the resistor to another part of the breadboard.
4)Connect another male to male wire to the side of the resistor which is not connected to the LED. Connect the opposite end of the wire to the GND on the Arduino UNO board.
It should look like this (image is taken from tinkercad therefore it looks animated)-
Open Arduino IDE and type the following code into the software (just ignore the comments)-
//This is the code for making and LED on and off for 1 sec
int ledPin = 13; //This defines at which digital pin the LED is connected
void setup()
{
//This code will run only once
pinMode(ledPin, OUTPUT); //This line of code defines if we want to keep digital pin 13 as output or input
}
void loop()
{
//This code will run forever
digitalWrite(ledPin, HIGH);//This will tell the LED to become on
delay(1000);
digitalWrite(ledPin, LOW);//This will tell the LED to become off
delay(1000);
}
If you have finished typing the code above then you can click on the verify option which will check your program-
After clicking on verify, it will ask you to save it, so if you want to save it you can type in a suitable name and save it where you want to. If you don't want to save it, you can click on 'cancel'.
After checking you code
First, connect the Arduino UNO board to the computer using the cable and then click on the upload icon -
Comments