Question
Would anyone know what I am doing wrong with this arduino code using Webmos D1 and the application Blynk? #include #include char auth[] = 2c1f0e13795b470e887461e169b29b7d;
Would anyone know what I am doing wrong with this arduino code using Webmos D1 and the application Blynk? #include
char auth[] = "2c1f0e13795b470e887461e169b29b7d"; //Blynk token char ssid[] = "DKJA-GUEST"; //Your WiFI SSID char pass[] = "shabbatshalom"; //Your Wifi password
// Define pin numbers const int echoPin = D6; const int trigPin = D7;
// Define variables long duration; int distance; int saveDis = 0;
SimpleTimer timer;
void sensorRead() { // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds saveDis = distance; // Save the distance to compare with the next value (for Blynk notification) distance = duration * 0.034 / 2; // Calculating the distance
Serial.println("Distance: " + String(distance) + "cm"); // Prints the distance on the Serial Monitor // Set Blynk notification for given range (in this case between 1-49cm) if (0 < distance && distance < 5) { Blynk.notify("Garage: Distance changed from " + String(saveDis) + "cm to " + String(distance) + "cm!"); } } void setup() { Blynk.begin(auth, ssid, pass); Blynk.notify("Check to see if your child is near your dishwasher detergent: " + String(ssid)); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); Serial.begin(115200); Serial.println("Motion Detector initializing..."); timer.setInterval(1000L, sensorRead); }
void loop() { Blynk.run(); timer.run(); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started