how do sensors work with computers??

VAGUE but i can take a guess at what you’re asking about:

you have some environmental sensor like a microphone or photoreceptor. these things produce an analog signal when stimulated (diaphragm in microphone moves back & forth in response to sound [pressure waves] which causes a nearby magnet/coil to vary the output signal in a way that corresponds to the pressure waves)

this signal is fed to an ADC (analog-to-digital converter) which has a little clock on it that polls the momentary voltage on the input line and generates a corresponding binary number to describe the voltage. a very high pitched noise might result in a number like 0xFFFFFFFF and silence would result in 0x00000000. these numbers are expressed in the form of a CMOS digital signal, which computers can understand.