In communication channels (including disk storage) it is necessary to somehow express the quantity of bits, as well as encoding which are 1's and which are 0. It is a common oversimplification to say that 0 is represented by the absense of something; and you've seen the problem with this: If I send a hundred 0's by being 'quiet' for one hundred bit times, the receiver can't be sure if that's exactly 100 bits.
The simplest approach is called Manchester encoding: For a zero, the signal is off for the first half of the time, and on for the second; for a one, it is the other way around. So, there's always a transition in the middle, which can be used when decoding the bits, to keep track of how many you've seen. There's still an issue, if you have a long string of 0's, it looks the same as a long string of 1's, so you need to make sure that each message starts with a pattern that has both 0's and 1's, so that it will be clear where the boundaries are.
https://en.wikipedia.org/wiki/Manchester_code
Manchester encoding was used in the early days of computer tape and disk storage, and with minor improvements, became something called MFM, which is used on floppy disks.
Nowadays, with much higher data rates being used everywhere, such methods are needed over short distances: in communications between the processor and the disk drives, and the monitor, for instance.
For digital radio, cable, and magnetic storage, Manchester has been replaced with methods of encoding multiple bits at once; for instance, QAM-64 might be used in digital cable, this encodes 6 bits at once by transmitting one of 64 possible "symbols", the symbols are designed to make it easier for the receiver to find the symbol boundaries and extract the 64 bits reliably.
Some extremes:
There is a technique called OFDM, used in digital radio, which encodes hundreds or thousands of bits in each 'symbol'; it is very computationally expensive to encode and decode, but the system is far more tolerant in the presence of 'echoes' from buildings, and similar problems.
GPS use 'Gold code': for a '0', you transmit a certain complex pattern, which looks much like random noise, repeated several times. For a '1' you transmit the same pattern, inverted. The data rate is quite low, but the advantage is that the signal can be detected from a very weak radio signal, and provides a very accurate time reference.
CDs are an interesting case too: each byte is encoded as 14 'channel bits', and there is a requirement that each run of 0's (or 1's) in the channel is at least 3 and at most 11 long, and this pattern becomes a series of optical 'pits' on the disk; pits which are too long or short cause problems for the decoder. The encoder also must form the 14-bit patterns to meet a requirement that the number of 0's and 1's must be roughly equal over any stretch of channel bits:
https://en.wikipedia.org/wiki/Eight-to-fourteen_modulation