I suppose that the topology on $D=\{0,1\}$ is discrete (which is the same as the subspace topology inherited from the real line).
The answer is easy - take the identity map $id_D \colon D\to D$.
This map is not constant and it is continuous - every map defined on a discrete space is continuous.
The definition of the connected space, which I am used to, is that it cannot be written as union of two non-empty disjoint open sets.
Notice that if $X=U\cup V$, where $U$ and $V$ are open disjoint set, then the map $f\colon X\to D$ defined by $f[U]=\{0\}$ and $f[V]=\{1\}$, i.e. $f(x)= \begin{cases} 0 & x\in U, \\ 1 & x\in V, \end{cases} $ is indeed continuous. Preimage of any open set is open: it suffices to check this for the basic sets $f^{-1}[\{0\}]=U$ and $f^{-1}[\{1\}]=V$-
Maybe the problem might be our intuition for continuous maps as maps such that the graph has no jumps and it can be sketched with one move of pencil. This intuition works fine for functions $\mathbb R\to\mathbb R$ but - as you can see - for disconnected subspaces of $\mathbb R$ it does not work anymore.