Hello, i’m very new to arduino and still learning (no programming background). Please be gentle to me. Btw, i’m helping my daughter to do this project. She really likes electronic especially arduino.
I’m making a simple IOT system on how to open/close a curtain by using NodeMCU + L298N + Blynk
What i expect : 1. when i press V0 = The curtain is opening for 5 seconds then stop
2. when i press V1 = The curtain is closing for 5 seconds then stop
*note that V1 and V2 are the switch button. Not push button. So, when V1-ON, V2 should OFF. Vice versa.
What happen : Nothing works.
*When i tried just by using NodeMCU, by giving the the pins HIGH or LOW. it works. So, it means that the wiring of the components and its pins are true.
It really confusing me. Sorry for my bad english.
I read the post by nick before posting the problem/topic, but i dont know how to post the code they others did (have a box for codes). Thanks so much
regards, HAMDAN
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "c5342bebfbce468db903e859d769ea62";
char ssid[] = " ";
char pass[] = " ";
int Positive = 15;
int Negative = 13;
long int stop1;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
stop1=millis()+5000; // 5 seconds timer
pinMode(Positive, OUTPUT);
pinMode(Negative, OUTPUT);
}
void loop()
{
Blynk.run();
}
BLYNK_WRITE(V0)
{
if (millis()<stop1)
{
digitalWrite(Positive, LOW); // open curtain
digitalWrite(Negative, HIGH);
}
else
{
digitalWrite(Positive, LOW); // stop the operation after 5 seconds
digitalWrite(Negative, LOW);
}
}
BLYNK_WRITE(V1)
{
if (millis()<stop1)
{
digitalWrite(Positive, HIGH); // close curtain
digitalWrite(Negative, LOW);
}
else
{
digitalWrite(Positive, LOW); // stop the operation after 5 seconds
digitalWrite(Negative, LOW);
}
}