Arduino Programming using Arduino IDE
-
Chapter-1->How to download Arduino IDE?3 Topics|1 Quiz
-
1.1 Introduction to Arduino IDE?
-
1.2 How to download Arduino IDE software?
-
1.3 Steps to install .exe file of Arduino IDE
-
1.1 Introduction to Arduino IDE?
-
Chapter-2-> Introduction to Arduino IDE3 Topics|1 Quiz
-
2.1 Why Arduino IDE?
-
2.2 How Arduino IDE works?
-
2.3 Explanation of default screen of Arduino IDE
-
2.1 Why Arduino IDE?
-
Chapter-3–> How to connect any board with Arduino IDE?4 Topics|1 Quiz
-
3.1 What are the different types of Arduino boards ?
-
3.2 What is USB cable?
-
3.3 Steps to connect board and port in Arduino IDE.
-
3.4 Advantages of Arduino IDE
-
3.1 What are the different types of Arduino boards ?
-
Chapter-4–>Steps to write a code in Arduino Programming5 Topics|1 Quiz
-
4.1 What is coding and C programming?
-
4.2 What is Arduino Programming?
-
4.3 Steps to write any code in Arduino IDE
-
4.4 How to open an example code in Arduino IDE
-
4.5 Explanation of different predefined syntax used in Arduino Programming?
-
Quiz-4->Steps to write a code in Arduino Programming
-
4.1 What is coding and C programming?
-
Chapter-5–>Introduction to Arduino Uno5 Topics|1 Quiz
-
5.1 What is Arduino and why we are using it?
-
5.2 Different types of Arduino boards
-
5.3 Explanation of Arduino UNO
-
5.4 Differentiate between digital and analog signals?
-
5.5 How to upload a code
-
5.1 What is Arduino and why we are using it?
-
Chapter-6–>Explanation of Variables and operators in programming5 Topics|1 Quiz
-
6.1 What are variables and data types?
-
6.2 What are operators?
-
6.3 Activity 1 : Led blink coding using Arduino IDE.
-
6.4 Activity 2 : Led on/ off using switch with arduino uno
-
6.5 How to upload the code
-
6.1 What are variables and data types?
-
Chapter-7–>How to use conditional statement and loops?6 Topics|1 Quiz
-
7.1 Introduction to loops and conditional statements.
-
7.2 Activity 3: Piano using Arduino Uno
-
7.3 Components Required
-
7.4 Circuit Connection
-
7.5 Coding using IDE
-
7.6 Compile and run
-
7.1 Introduction to loops and conditional statements.
-
Chapter-8–>How to use analog input in Arduino IDE ?6 Topics|1 Quiz
-
8.1 What are analog inputs and outputs ?
-
8.2 Activity 4: Controlling of Led using Potentiometer
-
8.3 Components Required
-
8.4 Circuit Connection
-
8.5 Coding using Arduino IDE
-
8.6 Compile and run
-
8.1 What are analog inputs and outputs ?
-
Chapter-9–>How to add libraries in Arduino IDE ?6 Topics|1 Quiz
-
9.1 What are libraries and header files?
-
9.2 Activity 5: Interfacing of Servo motor with Arduino Uno
-
9.3 Components Required
-
9.4 Circuit connection
-
9.5 Coding using Arduino IDE
-
9.6 Compile and run
-
9.1 What are libraries and header files?
-
Chapter-10–>How the Arduino Serial library performs serial communication?4 Topics|1 Quiz
-
10.1 What is Serial Communication?
-
10.2 How to do the serial communication in Arduino?
-
10.3 Activity 6: Interfacing of gas sensor with Arduino Uno and displaying amount of gas using serial communication
-
10.4 Compile and run
-
10.1 What is Serial Communication?
-
Chapter-11–>Interfacing of Dht11 sensor with Arduino4 Topics|1 Quiz
-
11.1 What is Dht11?
-
11.2 Activity7: Interfacing of DHT11 with Arduino Uno
-
11.3 Coding
-
11.4 Compile and run
-
11.1 What is Dht11?
-
Chapter-12–>Troubleshooting and Errors in Programming3 Topics|1 Quiz
-
12.1 What are Errors and Debugging?
-
12.2 Types of Errors
-
12.3 Common mistakes while Coding in Arduino IDE
-
12.1 What are Errors and Debugging?
-
Assessment6 Topics
-
Assignment 1-> Try to make a traffic light signal project.
-
Assignment 2-> Control the sequence of Led with potentiometer and Arduino Uno.
-
Assignment 3-> Distance measurement using Ultrasonic sensor and Arduino Uno
-
Assignment 4->Connect more push buttons in the Piano using Arduino Uno.
-
Assignment 5-> Alchohol detector using MQ-3 sensor and Arduino Uno.
-
Assignment-6-> Motion detector project using PIR sensor and Arduino UNO
-
Assignment 1-> Try to make a traffic light signal project.
Quizzes
6.4 Activity 2 : Led on/ off using switch with arduino uno
08/11/2021
To make this Led ON/OFF project using switch, first we will make the circuit connection of LED and Push button with Arduino Uno and then we will write a code in Arduino IDE.
Components Required :
LED |
Resistor |
Push button |
Arduino UNO |
Longer leg(+ve) |
Any of the one terminal of 220 ohm resistor |
——- |
——- |
——- |
Second terminal of 220 ohm resistor |
——- |
Digital Pin 2 |
Shorter leg(-ve) |
GND of Arduino via breadboard |
||
——- |
——- |
Any One terminal |
Digital Pin 4 |
——- |
Any of the one terminal of 10k ohm resistor |
Opposite terminal |
——- |
——- |
Second terminal of 10k ohm resistor |
——- |
GND of Arduino via breadboard |
Note : Push button have four terminals and to make connection we just need only two terminals of Push button. To learn more about the basic electronics components refer our basic electronics course.
Coding :
Steps to do coding in Arduino IDE
1. Open Arduino IDE from the desktop.You will be see the following page when you will open Arduino IDE:
2. Now, clear the page and then for writing a code first we will define a variable named “LED” and “button” with integer data type to assign which pin we are using of Arduino UNO.
Expression : int LED = 2;
int button= 4;
Note : Integers(int) are the data type that can store numbers.A data type, that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error.
3. In void setup ( ) function, we define the pin as input or output.So, a pin (Pin 2) of the Arduino as output for LED and another pin (Pin 4) as input for button. As mentioned in previous topics,we need to use the function pinMode to initialize a pin as input or output. Hence, write the pinMode functions for both LED and button pin in the setup function.
Expression :
void setup() {
pinMode(LED, OUTPUT);
pinMode(button, INPUT);
}
4. Now,after initialization of pin,we need to check the status of the switch.To check the status we need to use digitalRead() function.The digitalRead() function is used to to read the value of the digital pin.
Syntax: digitalRead(pin no. or variable name)
In the syntax the pin number or variable name is the number of the digital pin from where you want to read the data and connected the component.
As, we need to read the status of the button pin i.e. 4th pin . Create a variable before setup and name it as “buttonstate”, so that the value returned by the digitalRead function can be captured. Now in the void loop() function, assign the return value of the digitalRead of 4th pin to the buttonstate variable.
Expression:
void loop() {
buttonstate = digitalRead(4);
In the void loop() function, we write the main code and it run over and over again.
5. Next,we have to control the LED as per the button state.To control the Led we have to use if- else statement.
If-Else statements are the conditional statements which is used to check the statement and execute a block of code.If the condition in the “If statement” is true then the code in the if runs and if it is false then the else block of code runs.
Buttonstate variable gives to values HIGH or LOW.So, in the if statement we will compare buttonstate with LOW because Arduino will detect the logic LOW when the button is pressed. If the button is pressed or or the if stetement is true then the LED will glow using digitalWrite() function as done earlier and else the logic is false the LED will not glow.