5. Let $a$ be a real number. If the inequality $|\cos 2 x| \geqslant a \sin x$ holds for all $x$ in the closed interval $\left[-\frac{\pi}{3}, \frac{\pi}{6}\right]$, then the range of values for $a$ is ( ).
(A) $\{0\}$
(B) $[-1,0]$
(C) $\left[0, \frac{\sqrt{2}}{2}\right]$
(D) $[0,1]$
5.D.

Let $t=\sin x$, given $x \in\left[-\frac{\pi}{3}, \frac{\pi}{6}\right]$, we know $t \in\left[-\frac{\sqrt{3}}{2}, \frac{1}{2}\right]$.
The original inequality is equivalent to
$$
\left|1-2 t^{2}\right| \geqslant a t\left(-\frac{\sqrt{3}}{2} \leqslant t \leqslant \frac{1}{2}\right),
$$

which is equivalent to
$$
\left\{\begin{array}{l}
f(t)=2 t^{2}+a t-1 \leqslant 0, -\frac{\sqrt{2}}{2} \leqslant t \leqslant \frac{1}{2} ; \\
g(t)=2 t^{2}-a t-1 \geqslant 0, -\frac{\sqrt{3}}{2} \leqslant t \leqslant-\frac{\sqrt{2}}{2} .
\end{array}\right.
$$

Since the parabolas $y=f(t)$ and $y=g(t)$ open upwards, and $f(0)=-1, g(0)=-1$, therefore, equation (1) is equivalent to $f\left(-\frac{\sqrt{2}}{2}\right) \leqslant 0$ and $f\left(\frac{1}{2}\right) \leqslant 0$; equation (2) is equivalent to $g\left(-\frac{\sqrt{2}}{2}\right) \geqslant 0$, which means equation (1) is equivalent to $0 \leqslant a \leqslant 1$. And equation (2) is equivalent to $a \geqslant 0$, thus, the range of $a$ is $0 \leqslant a \leqslant 1$.