INPUT_PULLUP

Does your pin support INPUT_PULLUP? Generally there are two modes: INPUT and OUTPUT but sometime a pin also support INPUT_PULLUP this is useful for switch where you do not need extra big ohm resistor for pulling up or down the pin to ground or vcc when switch is not pressed.

You can set it to this and directly connect switch other leg to ground
by default the pin wil read 1 as because of pullup but as soon as switch is pressed circuit is completed with gnd it is 0

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s