Unit B · What your device can sense
What we are making: a page that does not just report a number — it reports a judgement. Is it dark in here, or not?
A light sensor gives you a number from 0 to 4095. That is a fact. But “dark” is not a fact — it is a line somebody drew, and today you draw it.
This is the same idea as the threshold in Level 2, and it will come back in your project. The number you pick is not right or wrong in itself; what matters is whether you can say how you chose it.
darkBelow in slot 2 to your number. Nothing else changes.| What you see | Why | What to do |
|---|---|---|
| Always says DARK | Threshold set above every reading you get. | Print the raw number and look at it before setting the line. |
| Reading is stuck near 4095 | The sensor is on a 5V pin, or it is DO not AO. | Use AO, and 3.3V. |
| Reading jumps about by hundreds | Normal for a cheap light sensor. | Keep the two states far apart and the wobble stops mattering. |
| Nothing changes when I cover it | Wrong pin, or the wire is loose. | GPIO 34 is input-only, which is fine — check the wire itself. |
In this session