Arduino Load Cell with L293D

When I run my code and put more than 13 grams on the load cell, my dc motor is supposed to run. However, my motor will not run the slightest bit. I have also attached documentation of my project wiring. Though, if it is not clear, the breadboard power-supply runs off of a 9V battery.

Here is my code:

#include <HX711_ADC.h> // https://github.com/olkal/HX711_ADC
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // LiquidCrystal_I2C library

//Initialize the pins for the motor
#define ENABLE 9
#define DIRA 10
#define DIRB 11

HX711_ADC LoadCell(4, 5); // parameters: dt pin, sck pin<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>
LiquidCrystal_I2C lcd(0x27,16,2); // 0x27 is the i2c address of the LCM1602 IIC v1 module (might differ)
void setup() {
  LoadCell.begin(); // start connection to HX711
  LoadCell.start(2000); // load cells gets 2000ms of time to stabilize
  LoadCell.setCalFactor(400); // calibration factor for load cell => strongly dependent on your individual setup
  lcd.begin(); // begins connection to the LCD module
  lcd.backlight(); // turns on the backlight
  //---set pin direction for motors
  pinMode(ENABLE, OUTPUT);
  pinMode(DIRA, OUTPUT);
  pinMode(DIRB, OUTPUT);
}
void loop() {
  LoadCell.update(); // retrieves data from the load cell
  float i = LoadCell.getData(); // get output value
  lcd.setCursor(0, 0); // set cursor to first row
  lcd.print("Weight[g]:"); // print out to LCD
  lcd.setCursor(0, 1); // set cursor to secon row
  lcd.print(i); // print out the retrieved value to the second row
  if (i > 13.00) { // weight is greater than 13g
   digitalWrite(ENABLE, HIGH); // Any value between 0 and 255
   digitalWrite(DIRA, HIGH);
   digitalWrite(DIRB, LOW);
  } else {
   digitalWrite(ENABLE, LOW); // Any value between 0 and 255
   digitalWrite(DIRA, HIGH);
   digitalWrite(DIRB, LOW); 
  }
}

Please help ASAP,
Leland

Please post your code here and I'll gladly take a look. Please read that link first about how to do that properly so it doesn't get trashed by the forum software. Also a schematic would maybe be useful. I can't really see how you have things wired up from here.

I just edited the post to include that essential information.

OP's image now visible

Though, if it is not clear, the breadboard power-supply runs off of a 9V battery.

Those square 9V batteries are great for super low current devices like a smoke detector. They can't supply enough current to turn a motor well. You'd be far better served to grab a handful of AA or AAA batteries instead. Especially once you add the display. That alone may be the problem.

What is the program outputting for the weight?

Delta_G:
Those square 9V batteries are great for super low current devices like a smoke detector.

Same for the breadboard supply.
Great to power things that require a few hundred milliamps, but not ok to power a motor.
Motor power should be connected directly to the L293D chip.
Leo..

Toxicl16:
the breadboard power-supply runs off of a 9V battery.

Well, that's your first problem.

The second is the old L293D: remember to supply it at least 2V more than what your motor needs, as that's the loss that chip incurs.

Delta_G:
What is the program outputting for the weight?

What do you mean?

Toxicl16:
What do you mean?

? ? ? ? ? You print the weight to the screen. What does it say that the weight is? I'm sorry, i thought that was pretty obvious what that meant.

I get the weight on the screen over 13 many times, for I weigh an object that is about 100 grams, so the screen says 100. I also fixed the power issue and routed the LCD and HX711 to a different power source.

I just made a redesign to give more power to the L293D, and power to the Arduino’s LCD.

There is no signal return path from L293 to Arduino.

JCA79B:
There is no signal return path from L293 to Arduino.

I am very sorry, but I do not know much about the L293D, but how can I fix this issue with the return path?

  1. Logic VCC (pin16 of the L293D) must be connected to Arduino 5volt.
  2. L293 ground (pin4 or 5 or 12 or 13 of the L293D) must also be connected to Arduino ground.

Motor supply must be connected to pin8 and ground of the L293D (correct in the diagram).

More info in the L293D datasheet.
Leo..

Wawa:

  1. Logic VCC (pin16 of the L293D) must be connected to Arduino 5volt.
  2. L293 ground (pin4 or 5 or 12 or 13 of the L293D) must also be connected to Arduino ground.

So I have done this and modified my code, nut the motor still will not run based on the condition of having more than 13 grams on the load cell.

Here is my new code:

#include <HX711_ADC.h> // https://github.com/olkal/HX711_ADC
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // LiquidCrystal_I2C library

//Initialize the pins for the motor
#define ENABLE 5
#define DIRA 3
#define DIRB 4

HX711_ADC LoadCell(6, 7); // parameters: dt pin, sck pin<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>
LiquidCrystal_I2C lcd(0x27,16,2); // 0x27 is the i2c address of the LCM1602 IIC v1 module (might differ)
void setup() {
  //---set pin direction for motors
  pinMode(ENABLE, OUTPUT);
  pinMode(DIRA, OUTPUT);
  pinMode(DIRB, OUTPUT);
  Serial.begin(9600); //Set the baud rate of the serial monitor
  //Calibrate the Load Cell and LCD
  LoadCell.begin(); // start connection to HX711
  LoadCell.start(2000); // load cells gets 2000ms of time to stabilize
  LoadCell.setCalFactor(400); // calibration factor for load cell => strongly dependent on your individual setup
  lcd.begin(); // begins connection to the LCD module
  lcd.backlight(); // turns on the backlight
}

void loop() {
  LoadCell.update(); // retrieves data from the load cell
  float i = LoadCell.getData(); // get output value
  lcd.setCursor(0, 0); // set cursor to first row
  lcd.print("Weight[g]:"); // print out to LCD
  lcd.setCursor(0, 1); // set cursor to secon row
  //lcd.print("Hello"); // print out the retrieved value to the second row
  lcd.print(i);
  if (i > 13) { // weight is greater than 13g
   digitalWrite(ENABLE, HIGH); // Any value between 0 and 255
   digitalWrite(DIRA, LOW);
   digitalWrite(DIRB, HIGH);
   delay(500); 
  } else {
   digitalWrite(ENABLE, LOW); // Any value between 0 and 255
   digitalWrite(DIRA, HIGH);
   digitalWrite(DIRB, LOW);
  }
}

Sorry, I forgot to add the new diagram.

//Initialize the pins for the motor
#define ENABLE 5
#define DIRA 3
#define DIRB 4

HX711_ADC LoadCell(6, 7);

That does not match the Fritzing picture.

How big is this motor.
The L293D is old technology, and can only control a tiny toy motor.
It also drops about 2.5volt of the power supply, so only about 3.5volt is available to the motor from that 6volt? battery pack.
Leo..