How can software make physical changes happen?


I’ve been thinking a lot about software and how it affects hardware. How is it that software, that runs on code, or some computer language, can affect the physical properties of the computer? For example what has to happen for a phone to physically shut down after pressing the shutdown button on a touch screen? Or how can it be that by pressing a button in a software, a physical movement can be made on an object? Going deeper, how can it be that a button press, or a touch can affect the state of the transistors?
This reminds me of the problem of consciousness, where in a computer a software is like the mind and that cannot phisically connect to the body.

In: 3

Basically, through electromagnetism. The simplest way to visualize it is that there are lots of tiny little electromagnets that can engage or disengage tiny switches. Tiny switches can control bigger switches, so on and so forth.

That’s what [drivers]( do.

Take a mouse. For simplicity let’s say it’s connected with a wire to the computer. There will be some pins that have a voltage, and some pins that don’t. Those voltages will trigger voltages in the processor at certain memory addresses, and those voltages will trigger other voltages. Eventually the patterns of voltages (and not) will trigger voltages in the wire that connects your screen to the computer, and the pixels on your screen will power up (shine) or not based on the patterns of voltages. To the computer, it’s just voltages or not. To you, it’s patterns of black and white dots – letters on a screen that you can understand.

A transistor can trigger other transistors and propagate voltages. Software, ultimately, is just a way to power up certain transistors in the processor, so that the mouse voltages create the right kind of domino effect to fill your screen with “words”.

There are different levels of “software”. The most basic level, is “if this pin is 0, then make this pin a 1. If this pin is a 1, then make this pin also a 1.” Literally transistor by transistor programming.

The higher levels of software are “languages” that organize things in a way that’s meaningful to humans. You type in your programming language “print the screen” and it generates the 150 pages of “if this pin is 0, then make this pin a 1, and if this pin is a 1, then make this other pin a 0” code to flip the transistors as necessary to get the printer to work correctly.

The main thing that transistors and other computer peripherals have in common is that they use electricity. When you provide an input to your computer of your phone, such as pushing the power button, an electrical impulse is sent into the transistors which are arranged in such a way that they’ll perform a set collection of actions. When those transistors need to tell another part of the device to do something, they send an electrical signal which is usually amplified by other electronics so that it produces an output (such as a noise or an image on a display).

Computer engineers have gotten very good over the decades at telling those transistors how to transform those electrical inputs into useful electrical outputs.

All a CPU ever does is follow instructions. The main instructions are add, load, store, jump and jump if positive. The CPU goes down the list of instructions, adding 2 to the current number, then storing it in position 5 in cache. It then might jump to a next list of instructions to work on another thing. These instructions are stored in RAM alongside the data.

As for your examples, a power switch will interrupt the current workings on the CPU, and tell it to read from the sleep mode instructions. These will be repeating instructions that display the time, and check for presses. If you fully turn it off, it will run a shut down routine, then the battery control chips will stop current from flowing by using transistors.

Physical movements within a phone do not happen at larger scales than electrons when anything happens. The electrons move because of the electric field in the wires. However for taptic and the shutter on the camera, electromagnets will be used to rapidly move a heavy bit of metal in the device. Same with shutter.

The button effects what happens because when an input is given, it is placed into RAM, the CPU when it gets time to see what inputs have been given will see the input, then branch to the instructions relevant.

It’s not really the software affecting the hardware. It actually is just the hardware. The hardware has a lot of different switches, these are called memory. The processor then keeps switching these switches based on other switches. What running a program on a hardware comes down to is carefully setting up these switches so that when we let the processor do its automatic switch switching, it does what we intended.