Hi All,
ive been struggling with the code side of this for days now and need some help. Its at the point id happily pay some one to write this for me.
A bit of history.
we live in a period house and want to automat wooden curtain poles. I thought id just buy some.... but there arnt any... ANYWHERE! So i thought id make some... HA HA!
i have learned enough fusion360 to fabricate all the parts and mounts and have the mechanical prototype up and running but when it come to control im struggling and dont in the short term have the time to learn c++. Ive been trying to cobble bits of code together from here and having some success but im getting strange errors.
The aim:
using D1 Mini and Blynk have a 5 button control on/off, open, close, jog open, jog closed.
On/Off make pin high/low to sleep pin on A4988 (apply/remove volts to motor)
Open: push button. start NEMA CW 17 motor and run until limit switch activated
Close: Push button. start NEMA CWW 17 motor and run until limit switch activated
Jog Open: push button. Jog NEMA CW 17 motor stop if limit switch activated
Jog Close: Push button. Jog NEMA CWW 17 motor stop if limit switch activated
ive bee playing with Robin2's coded and got the stepper working with blynk, but as soon as i start to mod it, it all goes pear shaped....
In the code below, ive added a pin (D4) for on off and im getting an error (attached screen grab) which is strange because earlier i had it working.....
Its really frustrating!
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
This example runs directly on ESP8266 chip.
Note: This requires ESP8266 support package:
https://github.com/esp8266/Arduino
Please be sure to select the right ESP8266 module
in the Tools -> Board menu!
Change WiFi ssid, pass, and Blynk auth token to run :)
Feel free to apply it to any other example. It's simple!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";
byte directionPin = D2;
byte stepPin = D3;
byte buttonOnOffpin = D4;
byte buttonCWpin = D5;
byte buttonCCWpin = D6;
boolean buttonCWpressed = false;
boolean buttonCCWpressed = false;
boolean buttonOnOffpressed = false;
unsigned long curMillis;
unsigned long prevStepMillis = 0;
unsigned long millisBetweenSteps = 1; // milliseconds
void setup()
{
// Debug console
Serial.begin(9600);
Serial.println("Starting Stepper Demo with millis()");
pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(buttonCWpin, INPUT_PULLUP);
pinMode(buttonCCWpin, INPUT_PULLUP);
pinMode(buttonOnOffpin, INPUT_PULLUP);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
curMillis = millis();
readButtons();
actOnButtons();
}
void readButtons() {
buttonCCWpressed = false;
buttonCWpressed = false;
buttonOnOffpressed = false;
if (digitalRead(buttonCWpin) == LOW) {
buttonCWpressed = true;
}
if (digitalRead(buttonCCWpin) == LOW) {
buttonCCWpressed = true;
}
if (digitalRead(buttonOnOffpin) == LOW) {
buttonOnOffpressed = true;
}
}
void actOnButtons() {
if (buttonCWpressed == true) {
digitalWrite(directionPin, LOW);
singleStep();
}
if (buttonCCWpressed == true) {
digitalWrite(directionPin, HIGH);
singleStep();
}
if (buttonOnOffpressed == true) {
digitalWrite(buttonOnOffPin, HIGH);
}
void singleStep() {
if (curMillis - prevStepMillis >= millisBetweenSteps) {
// next 2 lines changed 28 Nov 2018
//prevStepMillis += millisBetweenSteps;
prevStepMillis = curMillis;
digitalWrite(stepPin, HIGH);
digitalWrite(stepPin, LOW);
}
}