The Study Corner Light Indicator

Grade 5 Scratch 3.0 Simulation first Light Sensor Threshold
Simulation lab
Tool: Scratch 3.0
Open Scratch ↗
Simulator preview

Follow instruction sequences to guide the character to the goal.

📁 Tools ▴
  • Web browser (Chrome, Edge, Firefox)
  • Internet connection
  • Scratch 3.0 online editor

🔧 Build Your Study Light Indicator

1 Read ambient room illumination continuously using the micro:bit built-in light sensor (0-255).
2 Classify readings: below 60 is Dim light; 60 to 160 is Ideal light; above 160 is Glare.
3 Display an animated Moon icon for dim light, a Happy Face for ideal light, and Sun for glare.
4 Incorporate a 500ms sampling delay to prevent the LED matrix from flickering rapidly.
🧩 Block plan / Starter code ▴
// MakeCode micro:bit Light Monitor
basic.forever(function () {
    let light = input.lightLevel()

    if (light < 60) {
        basic.showIcon(IconNames.Asleep) // Dim light alert: turn on lamp!
    } else if (light <= 160) {
        basic.showIcon(IconNames.Happy)  // Perfect ergonomic study light
    } else {
        basic.showIcon(IconNames.Skull)  // Harsh glare warning!
    }
    basic.pause(500) // Sample twice per second
})

Multi-tier if-else branches categorize continuous light values into discrete health zones.

⚗️ Test your model

Test Condition / ActionExpected Result
Cover sensor with palm (light < 60)Displays Moon / Sleepy icon (turn on reading lamp)
Standard room lamp (60 <= light <= 160)Displays Happy Face icon (safe, ergonomic studying)
Direct bright torch beam (light > 160)Displays Glare warning icon (adjust lamp angle)
⚑ Try a challenge

Sound a soft auditory chime when the student has been reading in the dim light zone for over 3 minutes!

❓ Quick check
What is the primary danger to a student's vision when reading school textbooks in dim light below 35% brightness?

📖 Our Story & Concepts

Reading textbooks in poor evening light forces your pupils to dilate, causing severe eye strain, headaches, and reading fatigue. Conversely, studying under harsh direct bulbs creates reflective glare that irritates the retina.

The BBC micro:bit LED matrix doubles as a light sensor! By sensing photon energy striking the screen, it measures illumination from 0 (pitch dark) to 255 (blinding sun). Writing code that monitors thresholds transforms a small circuit into a practical health and ergonomics monitor.

</> Full Annotated Code Walkthrough

// Complete Light Monitor with Numeric Readout
let light = 0

input.onButtonPressed(Button.A, function () {
    // Show exact numeric light level when Button A is pressed
    basic.showNumber(input.lightLevel())
})

basic.forever(function () {
    light = input.lightLevel()
    if (light < 60) {
        basic.showIcon(IconNames.Asleep)
    } else if (light <= 160) {
        basic.showIcon(IconNames.Happy)
    } else {
        basic.showIcon(IconNames.Target)
    }
    basic.pause(500)
})

Multi-tier if-else branches categorize continuous light values into discrete health zones.

▷ Expected Results & Troubleshooting

Test Condition / ActionExpected Result
Cover sensor with palm (light < 60)Displays Moon / Sleepy icon (turn on reading lamp)
Standard room lamp (60 <= light <= 160)Displays Happy Face icon (safe, ergonomic studying)
Direct bright torch beam (light > 160)Displays Glare warning icon (adjust lamp angle)

⚑ Extension Challenges & Blueprints

⚑ Extension Challenges
  • Level 1: Press Button A to scroll the exact numeric light reading across the screen.
  • Level 2: Calibrate the threshold specifically for your own classroom by recording morning and evening light.
  • Level 3: Connect an external LED on Pin 0 that automatically lights up when room light drops below 60.

❓ Check Your Understanding

Question 1: What is the primary danger to a student's vision when reading school textbooks in dim light below 35% brightness?

Question 2: Which Scratch logic structure correctly classifies light level into Dim (<40), Ideal (40-80), and Glare (>80)?

Question 3: Why does our indicator show a 'Sun Warning' when ambient light exceeds 85%?

Question 4: What happens in our project when the light level returns to the 'Ideal' range (55%)?

Feedback appears after you check your answer.