File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
examples/interrupt_threshold Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -58,9 +58,16 @@ void setup() {
5858 Serial.print (F (" Threshold: " ));
5959 Serial.println (threshold);
6060
61- // Set up proximity interrupt for close detection
62- vcnl.setProxLowThreshold (0 );
61+ // Set up proximity interrupt for close/away detection
62+ // IMPORTANT: Interrupts fire on TRANSITIONS. The sensor must be below
63+ // the low threshold (far state) before it can trigger CLOSE by crossing
64+ // above the high threshold. Set low threshold above ambient so the
65+ // sensor starts in the "far" state.
66+ uint16_t lowThreshold = (ambient + threshold) / 2 ; // midpoint
67+ vcnl.setProxLowThreshold (lowThreshold);
6368 vcnl.setProxHighThreshold (threshold);
69+ Serial.print (F (" Low threshold: " ));
70+ Serial.println (lowThreshold);
6471 vcnl.setProxPersistence (VCNL4030_PROX_PERS_1);
6572 vcnl.setProxInterruptMode (VCNL4030_PROX_INT_BOTH);
6673
You can’t perform that action at this time.
0 commit comments