Hello,
I am trying to control the speed of a DC motor using the slider widget on Blynk. I am using an arduino mega, a motor shield, and an esp8266 module. If this isn’t possible with the slider, do you know of better widgets to use? I have posted my code and the error below. I removed my wifi info for privacy reasons. Thank you!
I’ve also noticed that when I add more void loops, the Blynk app reconnects/connects over and over. I try not to add to the main void loop because I know it should stay “clean”
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <AFMotor.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[] = "";
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);
AF_DCMotor motor(2);
int x = 0;
BlynkTimer timer;
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, millis() / 1000);
}
void getMotor()
{
motor.run(FORWARD);
static int value = 0;
static int delta = 30;
value += delta;
if (value > 255 || value < 0) {
delta = -delta;
} else {
Serial.print("LED on V2: ");
Serial.println(value);
motor.setSpeed(value);
}
x = motor.setSpeed(value);
Blynk.virtualWrite(V20, x );
}
void setup()
{
// Debug console
Serial.begin(9600);
// pinMode(dataIN,INPUT);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
timer.setInterval(5000L, getMotor);
#ifndef ESP8266
while (!Serial); // will pause Zero, Leonardo, etc until serial console opens
#endif
//motor.run(RELEASE);
motor.run(FORWARD);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}
wififix_motor:63:5: error: void value not ignored as it ought to be
x = motor.setSpeed(value);
^
Multiple libraries were found for "BlynkSimpleShieldEsp8266.h"
Used: C:\Users\Arduino\Documents\Arduino\libraries\Blynk
Not used: C:\Users\Arduino\Documents\Arduino\libraries\blynk-library-0.6.1
exit status 1
void value not ignored as it ought to be