Instructions

if fan_needed():
fan_on()
elif fan_not_needed():
fan_off()
print(stored, temp)
sleep(1000)
Adding Time Estimation
In project 5, you also calculated how long it takes your system to charge up to top of
charge, and discharge down to bottom of charge. These times significantly affect
the duty cycle of the system and will limit how long and how often you can use the
fan, based on your specific lighting conditions.
The MicroPython code below adds a time estimator based on these numbers, and
this will display a number on the screen indicating how many seconds of fan-time
are possible with the current charge.
The new/modified lines are marked in bold. This is program p6-estimator.py.
from microbit import *
TOC = 818 # c
BOC = 220
CHARGED = TOC/2
DISCHARGED = BOC
DISCHARGE_TIME = 250
RATE = (BOC - TOC) / DISCHARGE_TIME # m
HOT = 23
COLD = 20
override = False
temp = 0
def remaining(v):
return DISCHARGE_TIME - (v - TOC)/RATE
FONT = ( # WhaleySans font, 2x5 digits only
("99","99","99","99","99"),
("09","09","09","09","09"),
("99","09","99","90","99"),
("99","09","99","09","99"),
("90","90","99","09","09"),
("99","90","99","09","99"),
("99","90","99","99","99"),
Page 34