NMR (Nuclear Magnetic Resonance) basics

Nuclear magnetic resonance (NMR) spectroscopy gives information about the hydrocarbon skeleton of organic molecules through
the protons (hydrogens) on the carbons (1H NMR spectroscopy)
the carbons themselves (13C NMR spectroscopy).

Certain nuclei, of which 1H and 13C are examples, behave as though they are spinning magnets. If an external magnetic field is applied, they adopt an orientation aligned with (lower energy as in the image) or opposed to the external field (higher energy).

If the molecule is exposed to electromagnetic radiation of a frequency equal to the difference in energy between spin states, absorption of that energy results in some nuclei in the lower energy state flipping to the higher energy state.
 
Tap the image to see this.

At a particular magnetic field strength the difference in energy of the two spin states depends both
on the nucleus (1H or 13C)
on the molecular environment of the nucleus.

NMR spectra show the range of absorptions for a particular molecule.  In practice NMR spectra are determined by exposing the sample to a constant magnetic field and varying the strength of the electromagnetic field.  Conditions can be chosen so that the spectrum only shows absorptions due to
hydrogens in the molecule (1H NMR)
carbons in the molecule (13C NMR).