Hi Blynkers, i am in need of some help, The objective is to start the DC motor by using APP Button and the motor stopping when limit switch is triggered.
The limit switch is NC (HIGH) and LOW when triggered
I am using the old style WEMOS D1 board. I have wired it up and although the limit switch blinks the onboard led, it does not make D6 LOW. can somebody tweek my code for it to work please?
D6 is the motor pin
D5 is the limit switch
here is my code so far:-
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char server[] = "*********";
char ssid[] = "*********";
char pass[] = "***********";
char auth[] = "*************************";
const int motorIn1 = D6;
const int limitswitch = D5;
void setup()
{
pinMode(motorIn1,OUTPUT);
digitalWrite(motorIn1, LOW); // LED OFF on bootup
pinMode(limitswitch,INPUT);
digitalWrite(limitswitch, HIGH);
Serial.begin(115200);
Blynk.begin(auth, "***************", "*********", IPAddress(***********));
{
if (limitswitch == LOW){
digitalWrite(motorIn1, LOW);}
else{
digitalWrite(motorIn1, LOW);} }
}
void loop()
{
Blynk.run();
}
still struggling with this code, i have corrected the opening brackets which compiles and uploads to the Board but limit switch does not stop the motor, any ideas?
After a very quick glance at your code, I do not see any timers or interrupt routines to check for the state of any physical limit switch. Thus it is being ignored until you press a button or something in the App. And if it is an App timer, how frequently does it scan?