Navigasi Materi

Makecode Micro:bit 2# - Automatic Light

```html

💡 MakeCode micro:bit Lab

Simulator 02 — Automatic Light
Lampu Otomatis Berdasarkan Tingkat Cahaya
🧠 Learning Goal / Tujuan Pembelajaran

🇬🇧 Learn how a micro:bit can make a decision using an if...then...else statement.

🇮🇩 Memahami bagaimana micro:bit dapat mengambil keputusan menggunakan perintah if...then...else.

Light Sensor → Decision → LED

🖥️ Simulator

☀️
💡
Light Level / Tingkat Cahaya
80
☀️ BRIGHT / TERANG
Threshold / Batas: 50
Tekan RUN, lalu geser slider cahaya.

🧩 Program

English:
If the light level is below 50, turn the lamp ON. Otherwise, turn the lamp OFF.

Indonesia:
Jika tingkat cahaya kurang dari 50, nyalakan lampu. Jika tidak, matikan lampu.

forever
if light level < 50
set LAMP to ON
else
set LAMP to OFF
💡 Think about it!

The micro:bit checks the light level again and again.

Micro:bit terus memeriksa tingkat cahaya dan menentukan apakah lampu perlu menyala.

🎯 Practice — Latihan

The light level is 30. What should the automatic lamp do?

Jika tingkat cahaya adalah 30, apa yang harus dilakukan lampu otomatis?

🏆 Challenges — Tantangan

Challenge 1 — Make the Lamp Turn ON

Set the light level below 50. Then observe the lamp.

Atur tingkat cahaya di bawah 50, kemudian amati lampunya.

Challenge belum selesai.

Challenge 2 — Find the Decision

Which block makes the micro:bit choose between ON and OFF?

Blok mana yang membuat micro:bit memilih antara ON dan OFF?

Challenge 3 — Change the Threshold

Suppose the lamp should turn ON when the light level is below 30. What threshold should you use?

Jika lampu harus menyala ketika tingkat cahaya kurang dari 30, berapa batas (threshold) yang digunakan?

🔌💻

Now Try It with a Real micro:bit!

English
You've practiced with the simulator. Now create your automatic light program using the real Microsoft MakeCode editor.

Indonesia
Kamu sudah berlatih menggunakan simulator. Sekarang buat program lampu otomatis menggunakan Microsoft MakeCode yang sesungguhnya.

💡 Your Mission
  1. Open Microsoft MakeCode for micro:bit.
  2. Create a new project.
  3. Read the light level using the micro:bit.
  4. Use an if...then...else block.
  5. If the light is low, turn on the LED.
  6. If the light is bright, turn the LED off.
🚀 Open Microsoft MakeCode

Official Microsoft MakeCode for micro:bit

Kelas-Matematika Micro:bit Lab
Learn → Simulate → Think → Create
```