shocks in BDC...

hello Guys
i programmed a Brushless motor with this code :

#include <SoftwareSerial.h>
#include <Servo.h>
SoftwareSerial esp8266(2,3);
Servo brush_1;
char c;
int p=0;
char b;
int i=0;
int speed;
void arm(){
// arm the speed controller, modify as necessary for your ESC
setSpeed(0);
delay(1000); //delay 1 second, some speed controllers may need longer
}

void setSpeed(int speed){
int angle = map(speed, 0, 100, 0, 180);
brush_1.write(angle);
}
void setup() {

Serial.begin(9600);
pinMode(12,OUTPUT);
brush_1.attach(12);

}
arm();
}

void loop() {

if(Serial.available()){
b=Serial.read();
if(b=='^'){

speed=speed+5;
// brush_1.write(i);
setSpeed(speed);
}
delay(10);
if(b=='&')
{
speed=speed-5;

setSpeed(speed);
}

Serial.println(speed);
}
}

the problem is that when i change the speed of motor it have shocks...for example when the speed change from 60 to 65....
what can i do for it?
i don't want to use PID methods...
tnx for your time

void setup() {

Serial.begin(9600);
  pinMode(12,OUTPUT);
  brush_1.attach(12);
   
}
arm();
}

Well, the compiler barfed on that, didn't it?

Please post the actual you're having problems with, but this time in code tags.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

Why do you have a SoftwareSerial instance called esp8266 which is never used? Using Servo.h and SoftwareSerial.h together often causes problems so if you're not going to use it then gt rid of it.

Steve