Arduino Course on Artificial Intelligence: Button Controlled Light (Lesson 8)

[Video Teaching]

[Graphic Tutorial]

Lesson 8 Button Control Light

1. Course Introduction

Program branching can enhance interaction in programs. In the last lesson, we used a doorbell as a case study to explain the interaction design under a single boolean condition. In this lesson, we introduce boolean operations, achieving more complex program logic by creating a button-controlled light.

Components needed for this lesson: Arduino UNO, LED light, button.

2. Key Points of This Lesson

Program branching, boolean operations

3. Explanation of Required Modules

Boolean Operations: Arduino Course on Artificial Intelligence: Button Controlled Light (Lesson 8)

Location: Operators.

Module function: Perform “AND” operation on the boolean values to the left and right of the module.

4. Program and Flowchart

Program Diagram:

Arduino Course on Artificial Intelligence: Button Controlled Light (Lesson 8)

5. Related Knowledge Explanation

State Variables:

In this example, the variable is a state variable that records the light’s on/off state, which, together with the button state (high/low level state of port 5), determines the specific program branch statement executed.

Boolean Operations:

“AND” Operation:

When all boolean values involved in the operation are true, the result is true;

If any boolean value involved in the operation is false, the result is false;

“OR” Operation:

If at least one boolean value involved in the operation is true, the result is true;

If all boolean values involved in the operation are false, the result is false;

“NOT” Operation:

Not “true” is “false”, not “false” is “true”.

Learning Links for Arduino Course on Artificial Intelligence:
Lesson 1: Introduction to Arduino Basics
Arduino Course – Blinking LED (Lesson 2)
Free AI Arduino Course – SOS Signal Light (Lesson 3)
Free AI Arduino Course – Traffic Light (Lesson 4)
Arduino Course – Analog Input, Value Mapping, and Serial Monitor (Lesson 5)
AI Arduino Course – Dimming Table Lamp (Lesson 6)
AI Arduino Course – Doorbell: Logic Judgment and Digital Input (Lesson 7)
Scan to Follow
Information Technology Workshop

Arduino Course on Artificial Intelligence: Button Controlled Light (Lesson 8)

Arduino Course on Artificial Intelligence: Button Controlled Light (Lesson 8)

Leave a Comment

×