Hello
I am trying to control speed for brushless motor using widget slider on Blynk app. I use esp8266 module, esc brushless motor and brushless motor. Since this is my first time using Blynk app try to control speed for brushless motor so I try my own code base on servo lib and slider. the code work just fine able to verified and uploaded to esp8266 module but when I try to slide to increase the speed, brushless motor deosn’t show any response. I try check my code and I identify that the code for mapping speed for brushless motor and code for slider does not match. how am I suppose to control brushless motor using slider properly. can anyone teach me how to do it? thank you
Here I attached my code
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <Servo.h>
#include <BlynkSimpleEsp8266.h>
#define MotorPin D1
Servo esc;
// 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[] = "";
Servo servo;
BLYNK_WRITE(V0)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
pinValue= map(pinValue, 0, 1023, 0, 180);
esc.write(pinValue);
esc.writeMicroseconds(pinValue);
Blynk.virtualWrite(V1, pinValue);
Serial.print("V0 Slider value is: ");
Serial.println(pinValue);
}
void setup()
{
// Debug console
Serial.begin(115200);
esc.attach(MotorPin, 1000, 2000);
esc.writeMicroseconds(1000);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}
void loop()
{
Blynk.run();
}
1 Like
I assume that your slider is attached to pin V0 ?
How have you set-it up in the app - can you post a screenshot?
What does your serial monitor say?
Pete.
Here the picture for the serial monitor. the function works fine I able to get the value every time I slide left and right. I try use potentiometer to control the speed manually and its work esc brushless responce every time I rotate potentiometer. what i realize that the esc responce because of the potentiometer connected to the analog input.
I wanted to see a screenshot of the slider widget with the app in stopped mode, showing the virtual pin setting, mapping etc in the widget.
The serial monitor output needs to be copied and pasted into a post, not photographed or screenshotted.
Pete.
you mean screenshot using smartphone for the slider setting? and how can i copied and pasted the serial monitor? I’m very sorry sir this is my first time using Blynk app i barely know it.
A screenshot of the slider like this:
You select the data in your serial monitor using Ctrl-A then copy using Ctrl-C.
You can then paste into the forum, but it’s better to put triple backticks at the beginning and end of data so that it displays correctly.
Triple backticks look like:
```
Pete.
this is my serial monitor
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.6.1 on NodeMCU
[2078] Connecting to blynk-cloud.com:80
[2424] Ready (ping: 156ms).
V0 Slider value is: 0
V0 Slider value is: 0
V0 Slider value is: 0
V0 Slider value is: 0
V0 Slider value is: 65
V0 Slider value is: 140
V0 Slider value is: 211
V0 Slider value is: 149
V0 Slider value is: 109
V0 Slider value is: 170
V0 Slider value is: 84
V0 Slider value is: 204
V0 Slider value is: 109
V0 Slider value is: 0
V0 Slider value is: 108
V0 Slider value is: 138```
I don’t understand what you are trying to achieve with your map command, but it doesn’t seem to be working - based on your serial output.
Your slider shouldn’t be sending values higher than 255, but you’re mapping a range of 0-1023 across to a new range of 0-180.
Why not simply set your slider range to 0-180 and dispense with the mapping?
When you did the potentiometer test, did you also use pin D1 (defined as D1 not GPIO 5)?
Pete.
so you mean the value in blynk app and coding not match for controlling? And for the second question about slider range , can we setup only range without mapping value?
I use potentiometer connected to the analog pin and D1 connected to signal ESC brushless.
Yes. You can see the range values in the app, just set them to what you need.
You might want to try replacing D1 with 5 in your code, as the library may not understand the numbers that are printed on the MCU and expect the true GPIO number instead.
Pete.
okay i’ll try what exactly you told me sir.
Bro its your code is working
I need your code for my bi copter project using blynk app , so please share me the code
greeting sir, sorry the late reply. i just try a new code that you suggest previously and the code working well and now i know what is the problem for my project. thank you for your help sir i appreciate that.
1 Like
the old code as i mention early does not function to me that because i put a wrong command and its position.
1 Like
Send me the correct code for brushless motor please
Sir how to control brushless motor using arduino with Bluetooth module.
Do you know how the code should be?
Help me
@Rasheed please stop sending me private messages about this.
I don’t use Bluetooth, I don’t have a brushless motor controller and I don’t know how @achik.ter solved his problem. In addition, I don’t respond well to begging.
I look at the majority of posts that are made to the forum on a daily basis and if I have anything to contribute then I invariably do that via a post to the public forum rather than private message.
I would suggest that, if you have a specific compiler error message; problem with connecting your app to your device; a unwanted behavior with your project or any other problem then you start a new topic. This topic should outline in detail the hardware that you are using, the app type and version, the Blynk library version, your app/widget setup, your hardware setup, your code (correctly formatted with triple backticks) and full details the issues that you are encountering.
Pete.
What have you tried? What hardware do you have? What are the problems you are having with the code you wrote?
You need to provide more information, and show us what you are struggling with.
Nobody is just going to write the code for you.
Hello @achik.ter , i’m still new in this Arduino world. Where do you refer to this project? Can you give me the link? I am still learning step by step. Thank you