Exploring Arduino: Conditional Statements and Loops

Exploring Arduino: Conditional Statements and Loops
1 / 19
next
Slide 1: Slide
ArduinoHigher Education (non-degree)

This lesson contains 19 slides, with interactive quizzes and text slides.

time-iconLesson duration is: 60 min

Items in this lesson

Exploring Arduino: Conditional Statements and Loops

Slide 1 - Slide

This item has no instructions

Learning Objective
At the end of the lesson, you will be able to understand the concepts of if-else statements, else-if statements, the Arduino loop, and the Arduino while loop.

Slide 2 - Slide

This item has no instructions

What do you already know about Arduino conditional statements and loops?

Slide 3 - Mind map

This item has no instructions

Slide 4 - Slide

This item has no instructions

What is Arduino if-else?
Arduino if-else is a conditional statement that allows the program to execute different codes based on whether a specified condition is true or false.

Slide 5 - Slide

This item has no instructions

Slide 6 - Slide

This item has no instructions

What is Arduino else-if?
Arduino else-if is a conditional statement that provides an alternative condition to be tested if the initial condition in the if statement is false.

Slide 7 - Slide

This item has no instructions

Practical exercise #01 
Arduino's if, else if, and else statements to control an LED based on different conditions. In this example, we'll use a simulated scenario where the Arduino reads an analog input (like a potentiometer) and adjusts the brightness of an LED accordingly.

Slide 8 - Slide

This item has no instructions

Slide 9 - Slide

This item has no instructions

Slide 10 - Slide

This item has no instructions

Understanding Arduino Loop
Arduino loop is a function that runs continuously in a program, allowing the execution of code repeatedly without the need for manual intervention.

Slide 11 - Slide

This item has no instructions

How to Use Arduino Loop
In Arduino, the loop function is where the main program logic is placed, and it is executed repeatedly as long as the Arduino board is powered on.

Slide 12 - Slide

This item has no instructions

Exploring Arduino While Loop
Arduino while loop is a control flow statement that repeatedly executes a block of code as long as a specified condition is true.

Slide 13 - Slide

This item has no instructions

Benefits of Arduino While Loop
The while loop is useful for scenarios where a specific action needs to be repeated until a certain condition is met, providing a flexible and efficient way to control program flow.

Slide 14 - Slide

This item has no instructions

Slide 15 - Slide

This item has no instructions

Slide 16 - Slide

This item has no instructions

Slide 17 - Slide

This item has no instructions

Write down 3 things you learned in this lesson.

Slide 18 - Open question

Have students enter three things they learned in this lesson. With this they can indicate their own learning efficiency of this lesson.
Write down 2 things you want to know more about.

Slide 19 - Open question

Here, students enter two things they would like to know more about. This not only increases involvement, but also gives them more ownership.