hardware.pin9.configure(ANALOG_IN); hardware.pin8.configure(DIGITAL_OUT); local voltage = hardware.voltage(); server.log(format("Running at %.2f V", voltage)); local coolerState = "and Cooler is On"; server.log("Hardware Configured"); function checkPot() { local i; local rawValue; local potValue; local totalValue = 0; local iterations = 1000; local SetTemperature = 250; local hysteresis = 3; //average a bunch of data to give a nice steady number for(i = 0; i= SetTemperature + hysteresis){ hardware.pin8.write(1); coolerState = "and Cooler is On"; } //do it all again! imp.wakeup(0.3, checkPot); } hardware.pin8.write(1); server.log("Potentiometer Started"); imp.configure("Booze Cooler", [], []); checkPot();