Code for fan controller