Connecting a switch to an INPUT_PULLUP pin.

Hello everyone.

I have an arduino Mega and i want to use a switch on a pin declared as input with internal pullup resistor.
The tutorial states that in case of internally pulled up pins the HIGH state means that the sensor is off and the LOW state means that the sensor is on.
So if i want to read a closed switch i must have the switch connected between the input piun and ground. And in my code i will have to look for a LOW state to understand that the switch is closed.
Is that correct ?

Thank You !

Yes :slight_smile:

If you have trouble with thinking that way round start your sketch with

#define PRESSED LOW
#define RELEASED HIGH

And then just use PRESSED and RELEASED in your code.

That is a Good idea in order to keep things simple.

Thank you both !