+peripherals. The following program shows a system containing two devices. The
+first device --- the sensor -- contains a temperature sensor that measures the
+room temperature. The second device --- the actor --- contains a heater,
+connected to the digital pin \CI{D5}. Moreover, this device contains a led to
+indicate whether the heater is on. The following code shows an implementation
+for this. The code fully uses the framework. Note that a little bit of type
+twiddling is required to fully us the result from the \gls{SDS}. This approach
+is still type safe due to the type safety of \CI{Dynamic}s.
+
+\begin{lstlisting}[caption={Thermostat example}]
+thermos :: Task ()
+thermos = makeDevice "nodeM" nodeMCU >>= connectDevice
+ >>= \nod-> makeDevice "stm32" stm32 >>= connectDevice
+ >>= \stm-> sendTaskToDevice "sensing" sensing (nod, OnInterval 1000)
+ >>= \(st, [t])->sendTaskToDevice "acting" acting (stm, OnInterval 1000)
+ (\(BCValue s)->set (BCValue $ dynInt (dynamic s) > 0) (shareShare nod a))
+ >>| treturn ()
+where
+ dynInt :: Dynamic -> Int
+ dynInt (a :: Int) = a
+
+ sensing = sds \x=0 In {main=
+ x =. analogRead A0 :. pub x
+ }
+ acting = sds \cool=False In {main=
+ IF cool (ledOn LED1) (ledOff LED1) :.
+ digitalWrite D5 cool
+ }
+ nodeMCU = TCP
+\end{lstlisting}