void setHeater(int heaterStatus){ if (heaterStatus == LOW){ // Turn the heater on or off (and the LED) led1.off(); BLYNK_LOG("Heater off"); digitalWrite(heatPin, LOW); } else { led1.on(); BLYNK_LOG("Heater on"); digitalWrite(heatPin, HIGH); } }
void setTemperature(){ int t = temperature(); // Get the actual temperature // write to blynk Blynk.virtualWrite(widgetCurrent, t); // current temp display Blynk.virtualWrite(widgetChart, t); // update the blynk chart with the current temp if (RUNNING && !done){ time += TIMESTEP; // update the 'new' time int tg = target(time); // Find the target temperature Blynk.virtualWrite(widgetTarget, tg); // update 'target' temp UI // set the element on or off if (t < tg) { setHeater(HIGH); } else { setHeater(LOW); } Serial.print(time); Serial.print(", "); Serial.print(tg); Serial.print(", "); Serial.println(t); } else { setHeater(LOW); // belt and braces, make sure it is definitely off!! } // Keep the user informed if(done) { Blynk.virtualWrite(widgetLcd, "Finished!"); BLYNK_LOG("FINISHED "); } }
void BlynkWidgetWrite(BlynkReq& request, const BlynkParam& param) { BLYNK_LOG("No handler for writing to pin %d", request.pin); }
void BlynkWidgetRead(BlynkReq& request) { BLYNK_LOG("No handler for reading from pin %d", request.pin); }