Ibnovate Course 2 · The Rising Builders
⏱ 75 minLive session

Session 8 — Build a Smart Gadget

Duration: 75 min · Format: live online

What you'll learn: by the end, you can combine a sensor, a decision, and an output into a working gadget in the simulator, tune its threshold, and document it like an engineer.

Soft skill focus — Resilience

Today you'll also grow Resilience. Your first threshold almost never works — real engineering is staying with a gadget through round after round of testing and tuning until it behaves, not getting it right the first time.

What you'll need


Hook

Think about this:

Take a guess, then here's the reveal: it has all three pieces you've met — a sensor to sense, code to think, and an output to act. Today you'll snap those pieces into your own real gadget.


Teach — Plan it: Sense → Think → Act

Every gadget starts with a plan. Look at the diagram and pick one idea to build.

Look at this diagram:

Sense with a sensor, think with Arduino, act with an output

Here are three starter ideas:

Finish this sentence for your own gadget — "My gadget will sense ___, think (if ___), and act by ___."


Teach — Code the decision (the "Think")

The magic is an if statement — it lets the gadget decide for itself. Read the code line by line and name the Sense, Think, and Act.

Type and run this in Tinkercad:

void setup() {
  pinMode(13, OUTPUT);
}

void loop() {
  int light = analogRead(A0);   // SENSE
  if (light < 400) {            // THINK: is it dark?
    digitalWrite(13, HIGH);     // ACT: light ON
  } else {
    digitalWrite(13, LOW);      // ACT: light OFF
  }
}

⚠ Watch for the #1 misconception: it's tempting to expect it to work perfectly first try and give up when it doesn't. Remember — the number 400 is a threshold you tune, and real engineers spend most of their time testing and adjusting, not getting it right the first time.

Ask yourself: "What happens if I make the threshold 900 instead of 400? When would the LED come on then?" (Answer: it turns on much more easily — almost all the time.)


Activity — Build, test & tune

Build your gadget in the simulator, then work through these steps.

  1. In Tinkercad Circuits, add the Arduino, a sensor (e.g., photoresistor on A0), and an output (LED on pin 13 with a resistor). Wire it up.
  2. Add the decision code above (adapt it to your chosen gadget).
  3. Start Simulation. Cover the sensor — does the LED turn on?
  4. Tune the threshold: the number 400 decides when it triggers. Too sensitive, or not enough? Change it and re-test. This tuning is engineering.

Ask yourself: "What threshold worked for my gadget? How did I know?"

Debrief: be ready to share your gadget, your threshold, and one thing you changed while testing.


Check yourself

Try these — then check your answers:

  1. What are the three parts of a smart gadget?Sense → Think → Act — a sensor, an if decision, and an output.
  2. What does the if statement do? → It lets the gadget decide between options based on the sensor reading.
  3. What is the threshold? → The value that triggers the action (here, 400) — you tune it by testing.

Wrap-up


Tips & extra challenges

void loop() {
  int light = analogRead(A0);
  if (light < 300) {                 // very dark
    digitalWrite(13, HIGH);          // full
  } else if (light < 600) {          // dusk
    analogWrite(13, 60);             // dim (PWM)
  } else {                           // bright
    digitalWrite(13, LOW);           // off
  }
}

(3) Document it in a one-page engineering report: Problem → Design (Sense/Think/Act) → Build → Test results (what thresholds worked and how you found them) → Next steps. Record the actual sensor readings you measured for each state — that's real test data. (Prefer software? Build a data prototype instead — a mini analysis or model with a short report, same structure.)

Vocabulary

Term Meaning
if statement Code that decides between options
Threshold The value that triggers an action
Prototype A first working version
Debug Finding and fixing problems
Iterate Test → tweak → test again

Resources

Practice set

Practise on your own — extra tasks on if decisions, thresholds, and building/testing a gadget, easy to hard. Answers follow each arrow.

1. Read the decision. In if (light < 400) { ... }, when does the code inside run? → Only when the sensor reading is below 400 (i.e., when it's dark).

2. Plan a gadget. Fill in: "My gadget will sense , think (if ), and act by ___." for a heat alarm. → Sense temperature; think if temperature > threshold; act by sounding a buzzer.

3. Predict the tuning. The night-light triggers at light < 400. If you change it to light < 900, when does the LED come on now? → Much more easily — almost all the time, because most readings are below 900.

4. Add a buzzer (build task). Change the night-light so a buzzer on pin 8 beeps when it's dark instead of an LED.

void setup() { pinMode(8, OUTPUT); }

void loop() {
  int light = analogRead(A0);
  if (light < 400) {
    tone(8, 1000);      // beep at 1000 Hz
  } else {
    noTone(8);          // silence
  }
}

5. Spot the bug. A student writes if (light = 400) and the gadget acts weird. What's wrong? → = assigns a value; a comparison needs == (or <, >). They meant something like if (light < 400).

6. Three-way decision (harder sketch task). Rewrite the night-light so it's OFF in bright light, DIM at dusk, and FULL in the dark, using else if.

void loop() {
  int light = analogRead(A0);
  if (light < 300) {
    digitalWrite(13, HIGH);   // dark → full
  } else if (light < 600) {
    analogWrite(13, 60);      // dusk → dim
  } else {
    digitalWrite(13, LOW);    // bright → off
  }
}

7. Design a fair tuning test (hardest). Your night-light flickers on and off right at dusk. Describe how you'd find a threshold that stops the flicker. → Record the sensor reading at the exact light level where flicker happens, set the threshold clearly below it (or add a small gap / "deadband" between on and off levels), then re-test at that light level. Change one number at a time and note what happens — that's engineering iteration.

Going deeper (optional)

Optional — for when you've built the basic gadget and want it to behave like a real product.

Hysteresis — why real thermostats have a "gap." A single threshold flickers: right at the trigger point, tiny sensor wobble flips the output on-off-on-off. Real thermostats fix this with two thresholds — turn ON below one level, turn OFF above a higher level, and do nothing in between. Picture it with a heater: turn on below 18°C, turn off above 21°C — the 3-degree gap stops the constant clicking. If you're ready for a challenge, add this with a variable that remembers the current state and two if checks. It's a satisfying "aha": the fix for flicker isn't a better sensor, it's a smarter decision.

Calibration — every sensor is a little different. The "right" threshold isn't universal: a photoresistor in a bright room reads differently from one in a dim room, and two sensors rarely give identical numbers. That's why you tune the threshold rather than trusting one magic value. Real products calibrate: they take a reading in a known condition (e.g., "this is what 'dark' looks like here") and set the threshold relative to it. Measure your own sensor's "bright" and "dark" readings and set the threshold halfway between — a mini calibration.

Common mistakes & fixes

What's next

Unit 3 — Competition & Portfolio: the finale — you'll turn your work into a competition entry, a research paper, and a standout presentation.

Ibnovate · Build · Innovate
Type to search · Esc to close
Welcome back
Sign in to continue building.
Accounts are created by Ibnovate — ask your instructor for your login.
🔒