FYI. For every type of I/O and for some specific sensors, the standard declares control modules. A control module is made per I/O point or better for every tag. The control module keeps meta info, like the name of the tag, the physical connection(s) on the board and status information like the current status and the fact that the tag is polled by HMI or in hand or automatic mode. You don’t have to know anything of these control modules, all information is used internal but is readably for the user by means of e.g. the serial monitor or HMI. Making use of the standard, will make your live much easier.
Digital I/O. The standard input and output pins can be declared in the sketch. It is possible to connect a wide area of digital devices like buttons, PIR devices, relays… Remark; all inputs are declared with PULLUP. It means that when nothing is attached to a declared input it will by High.