انتقل للمحتوى
Robo EgyptRobo Egypt
☰ Course contents
Robo Maker: home
0. Lab tour1
1. The start: the Arduino6
2. Wiring and the traffic light4
3. Inputs: the button4
4. Sound and movement5
5. Sensors and numbers5
6. Distance, the screen and colours5
7. Motors and the car4
8. The project: the city's smart gate3
9. From blocks to C++ code5
10. Sensors and screens in code5
11. Smart systems5
12. Bluetooth: control from the phone1

The button and the question “if”

Section 3: Inputs: the buttonLesson 3.1 · ⏱ 8 min

Until now the Arduino has only talked. Now it will listen: the button is an input. We ask: “Is the button pressed?”, and choose what to do with if … else.

🧩 A button and an LED
Blocks: loop — repeats forever
🖥️ What happens on the stage?
As long as you press the button, the LED is on, and when you let go it goes off.

📌 Another example: the opposite: the button turns it off

The LED is always on, and when you press the button it goes off.

🧩 The opposite: the button turns it off
Blocks: loop — repeats forever
Not pressed: on
Not pressed: on
Pressed: off
Pressed: off
✍️ Practise
Build the button and the LED.
✍️ Practise here in the lessonor open the lab in a new page ↗

🎯 Challenge yourself

Easy

As long as you press, the LED blinks.

👀 Show the solution
🧩 Solution
Blocks: loop — repeats forever
In the lab
In the lab

Result: it blinks while you press.

Medium

Press once: it lights for 3 seconds, then goes off by itself (a stairway light).

👀 Show the solution
🧩 Solution
Blocks: loop — repeats forever
In the lab
In the lab

Result: it stays on 3 seconds after you let go, then goes off.

Hard

Press once: it lights up and stays on (there is no “else”).

👀 Show the solution
🧩 Solution
Blocks: loop — repeats forever
In the lab
In the lab

Result: it stays on after you let go.

Finished the lesson? Mark it so your progress counts.