Input devices such as the keyboard,
the mouse, a microphone or webcam
set and clear bits in the computer.
When you press a key on the keyboard,
its bit is set, and when you release it,
its bit is cleared — however not in your
computer, but in the keyboard's
microcontroller.
Microcontrollers are the simpler
cousins (smaller, slower, cheaper)
of the computer, but in principle,
they work in the same way.
In input devides, they are used to
format the input information so that
it can be transmitted efficiently
to the computer.
Without a keyboard microcontroller,
you would need one cable line
for every individual key each.
Instead, the microcontroller sends the
information about key state changes
(pressed, held, released) as a
sequential signal to the computer,
using up only very few cable lines.
There is a program built into the
device microcontroller for doing that,
and your computer has a compatible
program, the driver, to decode
the information from the device.
Output devices such as the TFT monitor,
the soundcard and the printer read bits
from the computer, often also by
help of further microcontrollers.
Memory devices such as hard disk drives,
CD/DVD drives and so on combine input
and output technologies, often even when
they are read-only: The mechanical drives
(HDD, CD/DVD) are steered by PC output
signals to read data on a PC input channel.