8 cells giving 9.5V means they're pretty much dead - if that's the problem.
Try some fresh batteries, but if they also put out only 9.5V, immediately remove them from their holders and correct the wiring error.
So i tried with 8 new fully charged AA batteries but i still get the stuttering from both the servo and dc motor.
You made all the corrections from post #29 ?
What's the voltage across the power supply with no load?
yes
11.52v
Check the voltage at Vin and GND on the motor shield
around 10.8v
Also, it's time to post your code so we can see what you are doing.
In the IDE under the EDIT menu item, click on "Copy for Forum" then just paste your code here.
Yep, will do when I'm home.
Right now I'm trying to hook up 8 LEDS for brake lights, front lights and blinkers for front and back. I'm having some trouble with the servo being delayed by the blinkers delay and of course the weird battery stuff. Also, I use RemoteXY to control everything.
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// you can enable debug logging to Serial at 115200
//#define REMOTEXY__DEBUGLOG
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266_HARDSERIAL_POINT
// RemoteXY connection settings
#define REMOTEXY_SERIAL Serial
#define REMOTEXY_SERIAL_SPEED 115200
#define REMOTEXY_WIFI_SSID "RemoteXY"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377
#include <RemoteXY.h>
// RemoteXY GUI configuration
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] = // 52 bytes
{ 255,3,0,0,0,45,0,17,0,0,0,24,1,200,84,1,1,3,0,4,
19,2,23,76,48,166,29,4,57,29,121,23,176,166,29,2,157,0,29,14,
1,16,29,190,36,79,78,0,79,70,70,0 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
int8_t slider_01; // from -100 to 100
int8_t slider_02; // from -100 to 100
uint8_t switch_01; // =1 if switch ON and =0 if OFF
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#define en_pin 13
#define hblink 4
#define vblink 5
#define bljus 6
#define fljus 7
#include <Servo.h>
Servo myservo;
int directionPin = 12;
int pwmPin = 3;
int brakePin = 9;
void setup()
{
RemoteXY_Init ();
myservo.attach(11);
RemoteXY.slider_02 = 0;
pinMode(directionPin, OUTPUT);
pinMode(pwmPin, OUTPUT);
pinMode(brakePin, OUTPUT);
pinMode(en_pin, OUTPUT);
digitalWrite(en_pin, HIGH);
pinMode(hblink, OUTPUT);
pinMode(vblink, OUTPUT);
pinMode(bljus, OUTPUT);
pinMode(fljus, OUTPUT);
}
void loop()
{
RemoteXY_Handler ();
int ms = RemoteXY.slider_02*-5+1520; // servo turn radius
myservo.writeMicroseconds(ms);
if(ms > 1520){
digitalWrite(vblink, HIGH);
RemoteXY_delay(500);
digitalWrite(vblink, LOW);
RemoteXY_delay(500);}
else{
digitalWrite(vblink, LOW);}
if(ms < 1520){
digitalWrite(hblink, HIGH);
RemoteXY_delay(500);
digitalWrite(hblink, LOW);
RemoteXY_delay(500);}
else{
digitalWrite(hblink, LOW);}
int motor = RemoteXY.slider_01;
if(RemoteXY.slider_01 < 0)
digitalWrite(directionPin, 0);
else
digitalWrite(directionPin, 1);
int pwmValue = 255 * abs (RemoteXY.slider_01) /100; // motor speed
analogWrite(pwmPin, pwmValue); // can't be negative
if(RemoteXY.slider_01 < 0)
digitalWrite(bljus, HIGH);
else
digitalWrite(bljus, LOW);
digitalWrite(fljus, (RemoteXY.switch_01==0)?LOW:HIGH);
}
I removed the converter for the ESP because it seems like the ESP can tolerate 5v Tx signals.
hblick is right blinkers pin
vblink is left blinkers pin
fljus is front lights pin
bljus is brake lights pin
Could it be the LED drawing too much current because without them the servo and motor work just fine. If so, is there a way I could make the LEDs draw less current.
Depends. It's not clear what kind of LEDs you're using.
Your diagram shows regular 5mm LEDs but without a current limiting resistor:

If this corresponds with reality, then that's not a good idea and problems can be expected.
However, there's also some of this in your code:
If that amounts to a 500ms delay, then that might be a big part of your problem, too.
Without specific information on your hardware or full code, it's going to be difficult to recommend anything.
Yes they are 5mm leds but do i need resistors for them? They have worked so far. Edit: "Oh yeah current limiting with resistor"
My hardware is
Arduino Uno Rev3 + Motor shield Rev3 (5v, 50 mA max)
DC motor (12v, 726 mA max)
Micro Servo (4.8-6v, 240 mA max)
ESP-8622 (3.3v, 170 mA max)
SparkFun BabyBuck Regulator 5v
8x 5mm LEDs
8x AA batteries in series (12v, approx. 2000mAh)
What do you mean about full code? I sent it, that's it.
I put some resistors on the LEDs and now it works, thanks :). The only thing now is to get rid of that delay on the servo.
I was referring to the RemoteXY thing, but I've already found it. Just wanted to check if it's indeed a regular blocking delay, which it turns out to be. Maybe that's part of your problem.
Good to hear the resistors on the LEDs made a difference!
How could i fix the blocking delay? I only want the LED to be affected.
This works fine I guess... The only problem is that sometimes when i quickly return the slider for the steering to 0 (slider_02) there is a risk that the LEDs are still on. I want them to be off if the slider is at 0 at all times. Please help ![]()
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// you can enable debug logging to Serial at 115200
//#define REMOTEXY__DEBUGLOG
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266_HARDSERIAL_POINT
// RemoteXY connection settings
#define REMOTEXY_SERIAL Serial
#define REMOTEXY_SERIAL_SPEED 115200
#define REMOTEXY_WIFI_SSID "RemoteXY"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377
#include <RemoteXY.h>
// RemoteXY GUI configuration
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] = // 52 bytes
{ 255,3,0,0,0,45,0,17,0,0,0,24,1,200,84,1,1,3,0,4,
19,2,23,76,48,166,29,4,57,29,121,23,176,166,29,2,157,0,29,14,
1,16,29,190,36,79,78,0,79,70,70,0 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
int8_t slider_01; // from -100 to 100
int8_t slider_02; // from -100 to 100
uint8_t switch_01; // =1 if switch ON and =0 if OFF
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#define en_pin 13
#define hblink 4
#define vblink 5
#define bljus 6
#define fljus 7
#include <Servo.h>
Servo myservo;
int directionPin = 12;
int pwmPin = 3;
int brakePin = 9;
int ledState1 = LOW;
int ledState2 = LOW;
unsigned long previousMillis = 0;
const long interval = 500;
void setup()
{
RemoteXY_Init ();
myservo.attach(11);
RemoteXY.slider_02 = 0;
pinMode(directionPin, OUTPUT);
pinMode(pwmPin, OUTPUT);
pinMode(brakePin, OUTPUT);
pinMode(en_pin, OUTPUT);
digitalWrite(en_pin, HIGH);
pinMode(hblink, OUTPUT);
pinMode(vblink, OUTPUT);
pinMode(bljus, OUTPUT);
pinMode(fljus, OUTPUT);
}
void loop()
{
RemoteXY_Handler ();
int ms = RemoteXY.slider_02*-5+1520; // servo turn radius
myservo.writeMicroseconds(ms);
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
if( RemoteXY.slider_02 < 0) {
if (ledState1 == LOW) {
ledState1 = HIGH;
} else {
ledState1 = LOW;
}
}
// set the LED with the ledState of the variable:
digitalWrite(vblink, ledState1);
if( RemoteXY.slider_02 > 0) {
if (ledState2 == LOW) {
ledState2 = HIGH;
} else {
ledState2 = LOW;
}
}
// set the LED with the ledState of the variable:
digitalWrite(hblink, ledState2);
}
int motor = RemoteXY.slider_01;
if(RemoteXY.slider_01 < 0)
digitalWrite(directionPin, 0);
else
digitalWrite(directionPin, 1);
int pwmValue = 255 * abs (RemoteXY.slider_01) /100; // motor speed
analogWrite(pwmPin, pwmValue); // can't be negative
if(RemoteXY.slider_01 < 0)
digitalWrite(bljus, HIGH);
else
digitalWrite(bljus, LOW);
digitalWrite(fljus, (RemoteXY.switch_01==0)?LOW:HIGH);
}
For one thing
if( RemoteXY.slider_02 < 0) {
should be
if( RemoteXY.slider_02 <= 0) {
No, i only want the blinkers to be on when i'm turning now when just going straight.
