Decreased motor RPM after more added components

Hello there, I have a 12V geared dc motor connected to a L298N motor driver (this is the only driver I could get at a store near me, and I feel like it is inferior due to power draw). Along side this I have a SG90 servo, potentiometer, two pushbuttons with 10k resistors, a 7 segment display, and an I2C lcd. The motor driver is connected to an 8 x AA battery pack, and my arduino mega is receiving extra power from a wall plug (actually a massage gun charger weirdly enough) providing 12V and 0.2A to the system along with the power provided by the serial cable plugged into my laptop. As you can see there are a lot of components drawing power from the system, and now my dc motor is not receiving enough current or power (I'm an electrics noob sorry if my terminology is wrong) to spin properly. Before wiring anything else up aside from the motor, the motor spun at good speed but now the potentiometer needs to be maxed out and I need to spin the motor by hand to get it going. How might I go about introducing more power to get the motor to spin? Thanks

Please read and use the topic "How to get the best ou of this forum."
Schematics and code..., please.

do you want wiring diagram or will a picture of the setup do? the code below is for when I had the lcd without the I2C backpack, everything else is the same

#include <LiquidCrystal.h>
#include <Servo.h>

Servo myServo;
// declare LCD pins
LiquidCrystal lcd(5, 6, 7, 8, 11, 12);

// declare pushbuttons, potentiometer, and servo
int button1 = 32;
int button2 = 33;
int pot = A0;

// L298N driver pins
int di1 = 1;
int di2 = 2;
int di3 = 3;
int di4 = 4;
int ENA = 10;
int speed1; // integer to store motor speed

// 7 segment display pins
int ssdA = 24;
int ssdB = 25;
int ssdC = 26;
int ssdD = 27;
int ssdE = 28;
int ssdF = 29;
int ssdG = 30;

// booleans to control gearing and states, allows for switching between gears
bool gear1 = true;
bool gear2 = false;
bool gear3 = false;
bool gear4 = false;
bool gear5 = false;
bool gear6 = false;

int currentState = 0; // variable to keep track of the current state

unsigned long buttonTime = 0;
unsigned long currentTime = millis();
unsigned long previousTime = 0;

void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  pinMode(pot, INPUT);
  pinMode(di1, OUTPUT);
  pinMode(di2, OUTPUT);
  pinMode(di3, OUTPUT);
  pinMode(di4, OUTPUT);
  pinMode(ENA, OUTPUT);
  pinMode(ssdA, OUTPUT);
  pinMode(ssdB, OUTPUT);
  pinMode(ssdC, OUTPUT);
  pinMode(ssdD, OUTPUT);
  pinMode(ssdE, OUTPUT);
  pinMode(ssdF, OUTPUT);
  pinMode(ssdG, OUTPUT);
  myServo.attach(9);

  digitalWrite(ssdA, LOW);
  digitalWrite(ssdB, HIGH);
  digitalWrite(ssdC, HIGH);
  digitalWrite(ssdD, LOW);
  digitalWrite(ssdE, LOW);
  digitalWrite(ssdF, LOW);
  digitalWrite(ssdG, LOW);
  myServo.write(0);
}

// print functions for 7 segment display to show gear number
void print1()
{
  digitalWrite(ssdA, LOW);
  digitalWrite(ssdB, HIGH);
  digitalWrite(ssdC, HIGH);
  digitalWrite(ssdD, LOW);
  digitalWrite(ssdE, LOW);
  digitalWrite(ssdF, LOW);
  digitalWrite(ssdG, LOW);
}

void print2()
{
  digitalWrite(ssdA, HIGH);
  digitalWrite(ssdB, HIGH);
  digitalWrite(ssdC, LOW);
  digitalWrite(ssdD, HIGH);
  digitalWrite(ssdE, HIGH);
  digitalWrite(ssdF, LOW);
  digitalWrite(ssdG, HIGH);
}

void print3()
{
  digitalWrite(ssdA, HIGH);
  digitalWrite(ssdB, HIGH);
  digitalWrite(ssdC, HIGH);
  digitalWrite(ssdD, HIGH);
  digitalWrite(ssdE, LOW);
  digitalWrite(ssdF, LOW);
  digitalWrite(ssdG, HIGH);
}

void print4()
{
  digitalWrite(ssdA, LOW);
  digitalWrite(ssdB, HIGH);
  digitalWrite(ssdC, HIGH);
  digitalWrite(ssdD, LOW);
  digitalWrite(ssdE, LOW);
  digitalWrite(ssdF, HIGH);
  digitalWrite(ssdG, HIGH);
}

void print5()
{
  digitalWrite(ssdA, HIGH);
  digitalWrite(ssdB, LOW);
  digitalWrite(ssdC, HIGH);
  digitalWrite(ssdD, HIGH);
  digitalWrite(ssdE, LOW);
  digitalWrite(ssdF, HIGH);
  digitalWrite(ssdG, HIGH);
}

void print6()
{
  digitalWrite(ssdA, HIGH);
  digitalWrite(ssdB, LOW);
  digitalWrite(ssdC, HIGH);
  digitalWrite(ssdD, HIGH);
  digitalWrite(ssdE, HIGH);
  digitalWrite(ssdF, HIGH);
  digitalWrite(ssdG, HIGH);
}

void blank()
{
  digitalWrite(ssdA, LOW);
  digitalWrite(ssdB, LOW);
  digitalWrite(ssdC, LOW);
  digitalWrite(ssdD, LOW);
  digitalWrite(ssdE, LOW);
  digitalWrite(ssdF, LOW);
  digitalWrite(ssdG, LOW);
}

void spinMe()
{
  digitalWrite(di1, LOW);
  digitalWrite(di2, HIGH);
  speed1 = analogRead(pot);
  speed1 = map(speed1, 0, 1023, 0, 100); // maps the throttle speed as a percentage, which can be displayed on an LCD
  analogWrite(ENA, speed1);
  Serial.println();

  lcd.setCursor(0, 1);
  lcd.print("Throttle %: " + String(speed1));
}

void loop()
{
  spinMe();

  if (digitalRead(button2) == HIGH)
  {
    delay(100);
    currentState++;
    if (currentState > 4)
      currentState = 4;

    switch (currentState)
    {
    case 1:
      gear1 = false;
      gear2 = true;
      print2();
      myServo.write(45);
      break;
    case 2:
      gear2 = false;
      gear3 = true;
      print3();
      myServo.write(90);
      break;
    case 3:
      gear3 = false;
      gear4 = true;
      print4();
      myServo.write(135);
      break;
    case 4:
      gear4 = false;
      gear5 = true;
      print5();
      myServo.write(180);
      break;
    }
  }

  if (digitalRead(button1) == HIGH)
  {
    delay(250);
    currentState--;
    if (currentState < 0)
      currentState = 0;

    switch (currentState)
    {
    case 0:
      gear1 = true;
      gear2 = false;
      print1();
      myServo.write(0);
      break;
    case 1:
      gear2 = true;
      gear3 = false;
      print2();
      myServo.write(45);
      break;
    case 2:
      gear3 = true;
      gear4 = false;
      print3();
      myServo.write(90);
      break;
    case 3:
      gear4 = true;
      gear5 = false;
      print4();
      myServo.write(135);
      break;
    }
  }
}

An as-built diagram ( even hand-drawn ) is almost always preferable to a picture or, ugh, fritzing diagram.

This is totally inadequate for driving a motor let alone a servo.

Yes it has been obsolete for decades and will loose a lot of voltage. Get a better one from an online supplier.

You can't even drive one servo direct from the power output of an Arduino. The supply needs to be connected externally, it must not go through the Arduino's internal regulator first. Look for an external power supply of at least 3 Amps capacity.

Also servos need 6.5V but will work off 5V only a bit slower.

Thank you for the guidance, my servo is actually very small and is driven fine by the Arduino, maybe there's a more efficient or acceptable way but the arduino seems to be capable of driving it on its own power, I've done it in a project previously that seemed to be adequate. Anyway, to power the motor with the 3 amp supply, should I just run the wall adapter into a jack -> screw terminal adaptor -> driver board? This is sadly an assignment due tomorrow, so a new driver might not be something I can get easily so I will try to work with what I have/can get from somewhere in person. Thank you for the help anyway.

Hi, @lucasanchez005

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Do you have a DMM? Digital MultiMeter?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

I suspect that your AA batteries have gone flat.
If your motor draws 500mA and you were running it for more than an hour, the AA battery voltage will probably be down to 1.25V.
1.25V x 8 batteries = 10V. With the maybe 2V drop in the L298, your motors are now only getting 8V.

But you said:-

So I am confused.

You never said:-

  1. This is an assignment.
  2. It had a very close deadline.

We can only know what you tell us. This would have affected our answers. Not sure how you are going to make a presentation without a schematic, but good luck.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.