ปฏิบัติการนี้กำหนดให้ระบบเปิดพัดลมเมื่ออุณหภูมิสูงกว่าค่าที่กำหนด
5.1 สร้าง Datastreams ที่เป็น Virtual Pin ไว้ ในที่นี้ใช้ V4 ให้มีชนิดข้อมูลเป็น Double
5.2 สร้าง widget ที่เป็น slider มากำหนดค่าให้ใช้ข้อมูล V4 มีสเกล 1-50 เอาไว้ใช้ปรับอุณหภูมิ
5.3 ในโค้ด ประกาศตัวแปร float TemperatureThreshold; เป็น global variable ไว้
5.4 เพิ่มสองฟังก์ชั่นต่อไปนี้ เพื่อ sync และส่งค่า Virtual Pin ไปยังแอป
BLYNK_CONNECTED() {
Blynk.syncVirtual(V4);
}
BLYNK_WRITE(V4) {
//reads the slider value when it changes in the app
TemperatureThreshold = param.asFloat();
}
5.5 เพิ่มโค้ดต่อไปในในตอนท้ายของฟังก์ชั่น sendSensor()
if (t>TemperatureThreshold) {
digitalWrite(D1, LOW); // enable pull up resistor
} else {
digitalWrite(D1, HIGH); // enable pull up resistor
}
5.6 ทดลองรันแอป และทำให้อุณหภูมิที่ DHT11 สูงขึ้น เพื่อดูผล