Level 2Project 2 · Session 29
29

Project 2 · Build 1 of 2

The input half

What we are making: the sensing half, working on its own and printing real numbers. Nothing else.

Only half, on purpose

Today you wire your input and nothing else. Print its value to the Serial Monitor, and watch it while you make the thing happen that it is supposed to detect.

Resist wiring the output. Every year, the teams that wire everything at once spend session 26 trying to work out which half is broken, and the teams that build in halves are finished early.

  1. Wire the input. Just the input.
  2. Print its value in a loop, with a short delay.
  3. Make the thing happen — walk towards it, warm it, press it, whatever it is.
  4. Write down the numbers. What does it read normally? What does it read when the thing is happening?
  5. Now choose your threshold from those two numbers, not from a guess. Put it somewhere between them, nearer the normal value.
  6. Write the threshold and one sentence saying why, in your notebook.
💡 Tip
The gap between your two numbers is the most useful thing you will learn today. If ‘normal’ is 300 and ‘happening’ is 310, your machine will be unreliable no matter how good your code is — and you have found that out now, with a session in hand to change the sensor or move it closer.

Before you leave

  • Your input wired and printing sensible numbers.
  • Two readings written down: normal, and happening.
  • Your threshold, chosen from those readings.
Challenge optional — only if you finish early
  • Make your machine do something sensible when the sensor is unplugged.
28. Choose it, and plan it