H and L
The slide switch swaps the comparator's two inputs. At H, DIG is HIGH while the input is Higher than the knob; at L, while it is Lower. Same threshold, same comparison, the answer turned over. It is the one setting on the board that a sketch can also make, by testing for LOW instead of HIGH.
Six pins, two positions
The switch is two switches in one body, moved by one slider. Its six pins sit in two rows of three. The middle pin of the top row goes to the comparator's minus input, the middle of the bottom row to its plus input. The end pins carry the knob and the input, crossed over: top row knob, input; bottom row input, knob.
A slide switch of this kind joins each middle pin to the end the slider is pushed toward. The maker's drawing does not say so in words, but that is how these are usually built, and it is the reading under which the printed letters make sense:
| Slider | Minus input | Plus input | DIG is HIGH while the input is |
|---|---|---|---|
| H, left | knob | input | higher than the knob |
| L, right | input | knob | lower than the knob |
What the letters mean
H and L do not mean HIGH and LOW; DIG is both, at different times. They say when DIG is HIGH: while the input is Higher than the knob, or Lower. So the letter is the question you want answered yes.
Swapping the inputs does not move the threshold. The knob sets the same voltage either way, and DIG changes at the same point; only the side that reads HIGH turns over.
Check it with the LED
You do not need a sketch to see which way it is set. The red LED lights while DIG is LOW. At H, it lights while the input is below the knob. At L, while it is above. Turn the input block one way and watch.
The same fix is always available in code: digitalRead(DIG_PIN) == LOW
instead of HIGH. The switch exists so the block's own LED, and anything
wired to DIG without a microcontroller, can be made to agree with you.
When it does not work
The switch is at the other letter. Slide it, or keep it and test for the other value in the sketch; either fix is fine. The LED will follow the change too, since it shows LOW.
A slide switch can stop halfway, touching neither side. Then one comparator input is connected to nothing and DIG does what it likes. Push the slider firmly to one end until it clicks.
Whichever makes HIGH mean the thing you care about. For an alarm that fires when a sound is loud, H: HIGH when louder. For a lamp that comes on in the dark, L: HIGH when darker. The book's light switch uses L.
Why DIG needs its pull-up, and why the LED shows the opposite of DIG.
The open collector and the light →Edit this page — content/books/analog-to-digital-signal/h-and-l.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Analog to Digital Signal
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.