Short Answer
//assuming sensor input pin is at pin4
``
//get input and store it var proximityInput = digitalRead(4); //will be either "HIGH" or "LOW" //check accordingly if ( proximityInput == "HIGH" ) { ....//do something } else if ( proximityInput == "LOW" ) { ....//do something else } else { ....//do something if neither }
Syntax is the same as C++.
edit
The code var proximityInput = digitalRead(4)
doesn’t work as expected. (digitalRead()
doesn’t return anything)
Adapt it according to the code here