Level is not a reading
Nothing pushes the roller back to the middle. Set the board level and it stays where it last rolled, so level usually reads the last side, or none if the roller stopped between contacts. Tipped towards a corner it can rest against one contact and read none. The switch has four answers and no way to say level.
Four answers, and none
The scan has five results: left, top, right, header, and none. It is tempting to read none as level. It is not. None means the roller is joining no pair, and that happens for reasons that have nothing to do with being level.
Level keeps the last side
Tip the board left and the roller rolls to the left side and joins A and B. Now set the board level. Gravity no longer pulls the roller anywhere, and nothing in the switch pushes it back to the middle, so it stays. The scan usually keeps reading left.
This block's old page said the opposite: that a flat board closes nothing and that this is the neutral state. On this switch, a level board reads whatever it read last. Sometimes the roller does stop between two contacts and the scan reads none, but that is luck, and a sketch cannot depend on it.
A corner can read nothing
Tip the board towards a corner, say with the left and header edges both going down, and the roller heads for that corner. It may land on the left side or the header side. It may also come to rest against the one contact in that corner, touching nothing else, and one contact joins nothing. The scan reads none.
So a none can mean "tipped towards a corner", "level and resting between contacts", or "rolling across right now". The scan cannot tell those apart, because the switch cannot.
Power-up is a guess
At power-up, the roller is wherever it was left. If the board is level, the first scan reports that: a side, or none. A sketch that wants to know the board's state at start-up has to wait for someone to tip it, or has to be mounted so that rest is always one side.
That last is the practical answer. Mount the block tipped a little towards one edge, or on its edge, and rest becomes a reading you chose. A tip-over alarm stands it header-down for that reason.
When it does not work
This block's old page promised that. It is not true of this switch. Level usually keeps reading the last side the board was tipped to, and none turns up whenever the roller rests against a single contact or between two, level or not. None means the roller is joining no pair, nothing more.
The roller rolled left the last time the board was tipped, and nothing has moved it since. Tip it another way and back and the reading follows. That is how this kind of switch works.
Give it one. Mount the block tipped a little towards one edge, so at rest the roller always sits on that side and reads it. Anything else is then a tilt. The tip-over alarm in this book mounts the block on edge, header down, for exactly this reason.
No. It has no angle to give, and it keeps its last answer when level. A spirit level, or an accelerometer if it has to be electronic, is the tool for that.
The roller rattles when the board is moved, and how to make a sketch wait for it to settle.
A knock is not a tilt →Edit this page — content/books/four-direction-tilt-sensor/level-is-not-a-reading.mdx
Questions about this product
See what other owners have asked, and read their solutions.
4-Direction Tilt Sensor
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.