Instructions

Code for the Intelligent Cooling Fan (MakeCode)
You can access this code from this link:
https://makecode.microbit.org/_ATgfJtK9fMa5
How it Works
Using the numbers for TOC and BOC from project 5, fill in the CHARGED and
DISCHARGED constants in this program, to calibrate it for your specific
environment. Note how the CHARGED constant is divided by two; this is because
you want to allow your fan to start if things are getting hot, even when there is some
charge in the Solar Store, rather than waiting for full charge.
This program uses hysteresis to prevent lots of jittery switching. This just means
that there are two thresholds, one for turning on and one for turning off, and the
values are slightly different. This is just like how a central heating thermostat works,
to prevent repeated boiler starting and stopping. Both the temperature sensing and
the stored charge sensing have hysteresis applied to them to stop this jittering.
Without hysteresis With Hysteresis
blue line – sensed temperature, red line – output (fan on/off)
Page 31