Back to Course

Arduino Programming using Arduino IDE

0% Complete
0/0 Steps
  1. Chapter-1->How to download Arduino IDE?
    3 Topics
    |
    1 Quiz
  2. Chapter-2-> Introduction to Arduino IDE
    3 Topics
    |
    1 Quiz
  3. Chapter-3–> How to connect any board with Arduino IDE?
    4 Topics
    |
    1 Quiz
  4. Chapter-4–>Steps to write a code in Arduino Programming
    5 Topics
    |
    1 Quiz
  5. Chapter-5–>Introduction to Arduino Uno
    5 Topics
    |
    1 Quiz
  6. Chapter-6–>Explanation of Variables and operators in programming
    5 Topics
    |
    1 Quiz
  7. Chapter-7–>How to use conditional statement and loops?
    6 Topics
    |
    1 Quiz
  8. Chapter-8–>How to use analog input in Arduino IDE ?
    6 Topics
    |
    1 Quiz
  9. Chapter-9–>How to add libraries in Arduino IDE ?
    6 Topics
    |
    1 Quiz
  10. Chapter-10–>How the Arduino Serial library performs serial communication?
    4 Topics
    |
    1 Quiz
  11. Chapter-11–>Interfacing of Dht11 sensor with Arduino
    4 Topics
    |
    1 Quiz
  12. Chapter-12–>Troubleshooting and Errors in Programming
    3 Topics
    |
    1 Quiz
  13. Assessment
    6 Topics
Lesson 7, Topic 1
In Progress

7.1 Introduction to loops and conditional statements.

08/11/2021
Lesson Progress
0% Complete

Loops are the  set of instructions that are repeated until the certain condition have reached. It is used to repeat the code a certain number of times.

Let see a diagram to understand how loop runs?

As you can see in the diagram,if the test condition is true then the loop is executed and if it is false then execution of code go out of the loop.After the loop is executed it again go to the loop entry and then again check the condition and this goes on repeating.

The sequence of statements in the code to be executed is kept inside the curly braces { } known as the Loop body. After every execution of the loop body, condition is tested, and if it is found to be true then the loop body is executed again. When the condition is false, then loop body is not executed, and execution breaks out of the loop.

There are three types of loops:

  1. while loop : this loops are the entry loops.
  2. for loop : this loop runs the statement repeatedly until the condition is satisfied
  3. do while loop : In this loop, some situation are in do statement which evaluates the body of the loop first and at the end, the condition is checked using while statement.

A conditional statement is a set of rules performed if a certain condition is met. It is sometimes referred to as an If-Then statement, because IF a condition is met, THEN an action is performed.

For example:

If you want to drink chocolate shake, then you go to the shop and keep a condition that if you have a chocolate shake then give to me else give mango shake.Similar way these conditional statements runs,if the condition is true then it runs continuously and if it is false then else condition runs.