Hello, i am trying to create a project for my school, but i ran into some issues. My task was to create a program that would allow me to measure the temp and moisture in a room, and controll the ‘‘heating’’ via slider in the blynk app (the temp/moisture info should be displayed there too) I got trough the info part but i am stuck on the slider controlling the ‘‘heating’’. In my case its the LED on my MKR 1000 (wifi). Im supposed to turn the LED on once my slider goes over 50%. I tried looking on the forums but couldnt find anything. Please help.
This is what my code looks like so far, as i said it connects to my phone and shows the info i need, i just need help with the slider.
Im using a
DHT11 sensor
Arduino MKR 1000 (wifi)
Blynk for android
(led on my mkr1000)
#define BLYNK_PRINT SerialUSB
#include <SPI.h>
#include <WiFi101.h>
#include <BlynkSimpleWiFiShield101.h>
#include <DHT.h>
char auth[] = "o";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "o";
char pass[] = "o";
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(2,11);
BlynkTimer timer;
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Blynk.virtualWrite(V5, t);
Blynk.virtualWrite(V6, h);
}
void setup()
{
pinMode(14, OUTPUT);
// Debug console
SerialUSB.begin(9600);
Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
dht.begin();
timer.setInterval(1000L, sendSensor);
}
BLYNK_WRITE(V1){ // This function gets called each time something changes on the widget
int value = param.asInt(); // This gets the 'value' of the Widget as an integer
analogWrite(14 value); // this send a PWM signal based on 'value' to the GPIO pin
}
void loop()
{
Blynk.run();
timer.run();
}
This is my first post here so im sorry in advance if i messed something up, had to turn to this website since my mentor isnt of any help.