Bits need a carrier
We want to send four bits, 1 0 1 1, one every millisecond: a bit time Tb = 1 ms, so 1000 bits per second. Bits cannot fly through the air on their own. They must ride on a radio wave.
An oscillator makes a steady cosine wave, the carrier: c(t) = cos(2π·4000·t). At 4 kHz it fits exactly 4 cycles into each bit. A steady wave carries no news: to send bits we must change something about it.
Keying the amplitude
Amplitude-shift keying changes the wave's height. Its simplest form, on-off keying, works like a switch: the carrier goes out for a 1 and is blocked for a 0. So s(t) = b·A·cos(2π·fc·t), with A = 1 V.
This is the average spectrum of a long random OOK stream, computed with a DFT. A spike sits at the carrier, 4 kHz. Around it, the main hump runs from 3 to 5 kHz: twice the bit rate wide.
Keying the frequency
Frequency-shift keying keeps the height and changes the pitch. The oscillator sends 5 kHz for a 1 (5 cycles per bit) and 3 kHz for a 0 (3 cycles). The wave is always 1 V tall.
FSK has two spikes, at 3 and 5 kHz, each with its own hump. Its main lobes span 2 to 6 kHz: 4 kHz wide, twice ASK's (the white curve). FSK pays for its steady height with bandwidth.
Getting the bits back
The receiver multiplies what arrives by its own 4 kHz cosine and adds up (integrates) over each bit. A 1 builds up to 0.50 V·ms; a 0 stays at 0. Above 0.25 means 1: it reads 1 0 1 1.
Move the receiver farther away and only 40% of the height arrives. Now a 1 builds up to just 0.20 V·ms, below the fixed threshold of 0.25. All 3 ones are read as zeros: 0 0 0 0.
An FSK receiver runs two correlators, one at 5 kHz and one at 3 kHz, and picks the larger. At 40% strength they reach 0.20 and 0 V·ms: still 1 0 1 1. Only which one is bigger matters.
In code and in the world
In Python with numpy, one FSK decision takes four lines. Make 32 sample times, the two reference cosines, then compare r @ c1 with r @ c0. The @ multiplies sample by sample and adds up: a correlator.
ASK is the simplest: garage remotes near 433.92 MHz use on-off keying. FSK needs more bandwidth but copes with changing signal strength; Bluetooth uses a smoothed FSK called GFSK. Next: keying the phase.
The working
# step 1/11 · bits bits 1 0 1 1 bit time Tb = 1 ms bit rate Rb = 1 / Tb = 1000 bit/s the numbers are scaled down so you can see every wave cycle; a real radio link uses carriers of MHz or GHz and far faster bits
The numbers are scaled down so each carrier cycle can be seen: 1000 bits per second on carriers of 3 to 5 kHz, 1 V tall, sampled 32000 times a second. Real radio links use carriers of MHz or GHz. Every value and curve in the figure is computed from this model. The waves in the air move in slow motion: a real radio wave crosses a room in a few nanoseconds. The 40% received strength is a chosen example, and noise is left out so the effect of strength alone is clear. The spectra are averages of |DFT|² over 64 blocks of 16 random bits, in decibels relative to the highest bin; values below -45 dB are drawn at -45 dB.