They don’t.
Circuit boards are boards of materials that don’t let electricity pass through them, with loads of holes in them, with each hole surrounded in a conductive material. So you can connect electronic parts to each hole, in certain orders, to make electricity run in a certain path through different components.
How they do this is complicated, but essentially comes down to “if this, then that”. This is a field of thought that was referred to as logic for hundreds of years, to try and distill all thinking down to simple yes/no paths, and that became very relevant with the advent of electronic computing.
Latest Answers