Skip to main content
+ link to port manipulation.
Source Link
Edgar Bonet
  • 45.2k
  • 4
  • 42
  • 81

For reading, e.g., PB2, you would test

PINB & _BV(PB2)

where PINB is the port input register and _BV(x) is a macro defined as (1 << (x)).

C.f. the datasheet for the relevant port names.

See also the Arduino tutorial on port manipulation.

For reading, e.g., PB2, you would test

PINB & _BV(PB2)

where PINB is the port input register and _BV(x) is a macro defined as (1 << (x)).

C.f. the datasheet for the relevant port names.

For reading, e.g., PB2, you would test

PINB & _BV(PB2)

where PINB is the port input register and _BV(x) is a macro defined as (1 << (x)).

C.f. the datasheet for the relevant port names.

See also the Arduino tutorial on port manipulation.

Source Link
Edgar Bonet
  • 45.2k
  • 4
  • 42
  • 81

For reading, e.g., PB2, you would test

PINB & _BV(PB2)

where PINB is the port input register and _BV(x) is a macro defined as (1 << (x)).

C.f. the datasheet for the relevant port names.