Studyfin Studyfin ✨ Sign up free

Robotics & physical computing

Grade 8 · Coding · Free lesson

Hey there! Ready to build something awesome? Today, we will design a smart robot nightlight that turns on when it gets dark!

Physical computing means connecting software to the real world. We write code on a computer, and that code controls real physical objects like sensors, motors, and lights.

chip

Every smart gadget follows a simple design process. First, we find a problem, like needing a light at night. Next, we plan a sequence of steps to solve it.

1. Plan2. Code3. Test

To make our nightlight smart, we use a conditional 'if-then' statement. If the light sensor detects darkness, then the code triggers an event to turn the light bulb on.

If Dark → Light ON
✏️ Worked example

Let's design a program for an automatic nightlight. Walk through the design process step-by-step to create the logic for this everyday device.

  1. Identify the Goal: We want a light bulb to turn on automatically only when a room gets dark.
  2. Choose the Inputs and Outputs: The input is a light sensor (detects brightness). The output is an LED bulb.
  3. Write the Sequence: Create a loop that constantly checks the light sensor's value.
  4. Add the Conditional: Inside the loop, add an 'if-then-else' block. If 'light level < 30', then set 'LED to ON'. Else, set 'LED to OFF'.
  5. Test and Refine: Run the program. If the light turns on too early, adjust the threshold number from 30 to a lower number.
tennis
Want the full interactive lesson — quiz, animations, and Finn cheering them on?

More Coding lessons