Need some help here. I'm working on a code to do multiple things. Here are the components:
- Arduino Mega board
- TS-25GA370H-45, 12volt DC motor
- HV711 sensor
- 1K stain gauge
- LCD 1602 module
- (2) LED lights
- Active buzzer
- Breadboard
My code works like this:
When the code is uploaded, the DC motor starts turning and the LCD displays the stain force of the guage (in this case "0" on startup). I programed the coded with a max strain force of 225 grams. When I apply force to the strain gauge that exceeds 225 grams, the motor stops turning and the LED's and buzzer are actived. This work as supposed to (I have no issue with this).
My issue that I'm having is the torque of the motor. I have the motor connected to a drum that weight about 1.5lbs. The motor can turn the shaft of the drum but doesn't have the required torque to turn the shaft and motor. I can't swap out any of the components I listed above but I can add components like a " L298N Motor Drive Controller Board Module Dual H Bridge DC Stepper For Arduino", but that is all I have and not sure how to use this.
My question:
How can I modify my code to increase the torque of the motor? Or increase the speed on startup? I did try connecting a 9V battery as well to the motor's wiring and this did increase the speed a little bit, along with slight increase torque but when the strain gauge hit the 225 gram limit, the motor only slowed down and not off like it did when it was just on the 5V of the Arduino board. Any help or suggestions will be greatly appreciated.
Code:
#include <HX711.h> // HX711 weight sensor library
#include <LiquidCrystal.h> // LCD display library
LiquidCrystal lcd(30, 32, 34, 36, 38, 40); // LCD display: (rs, enable, d4, d5, d6, d7)
const int LOADCELL_DOUT_PIN = 44; // HX711 wiring
const int LOADCELL_SCK_PIN = 42; // HX711 wiring
HX711 scale; // HX711 scale reading
long duration;
int weight; // HX711 weight reading
int led1 = 10; // LED1 light
int led2 = 12; // LED2 light
int buzz = 11; // Active buzzer
int motor = 2; // DC motor
void setup() {
lcd.begin(16,2); // LCD screen initiated
//lcd.clear(); // LCD screen cleared
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); // HX711 reading DT & SCK pins
pinMode(led1, OUTPUT); // LED1 light
pinMode(led2, OUTPUT); // LED2 light
pinMode(buzz, OUTPUT); // Active buzzer
pinMode(motor, OUTPUT); // DC motor
}
void loop() {
lcd.clear(); // LCD screen cleared
if (scale.is_ready()) { // HX711 - Zero out scale
long reading = scale.read(); // HX711 - Reading for weight reading
weight = ((302443.9333-reading)/-1830); // HX711 calculation for weight
lcd.setCursor(0,0); // HX711 - Sets the cursor to col 0, row 0 on LCD
lcd.print("Weight(gm):"); // HX711 - Displays "Weight(gm):" on LCD
lcd.print(weight); // HX711 - Displays Weight value on LCD
digitalWrite(led1, LOW); // LED1 light turns OFF
digitalWrite(led2, LOW); // LED2 light turns OFF
digitalWrite(buzz, LOW); // Active buzzer OFF
digitalWrite(motor, HIGH); // DC motor ON
if (weight > 225){ // HX711 weight limit for alarms
lcd.setCursor(0,0); // HX711 - Sets the cursor to col 0, row 0 on LCD
lcd.print("Bin is full....."); // HX711 - Displays "Bin is full....." on LCD
lcd.setCursor(0,1); // HX711 - Sets the cursor to col 0, row 0 on LCD
lcd.print("MaxWeight: 225g"); // HX711 - Displays "Bin is full....." on LCD
digitalWrite(led1, HIGH); // LED1 light turns ON
digitalWrite(led2, LOW); // LED2 light turns OFF
digitalWrite(buzz, HIGH); // Active buzzer ON
digitalWrite(motor, LOW); // DC motor OFF
delay(200); // Delay of 0.2sec reading on LCD
digitalWrite(led1, LOW); // LED1 light turns OFF
digitalWrite(led2, HIGH); // LED2 light turns ON
digitalWrite(buzz, LOW); // Active buzzer OFF
digitalWrite(motor, LOW); // DC motor OFF
delay(200); // Delay of 0.2sec reading on LCD
}
} else {
lcd.print(""); // HX711 - Displays "Error!" on LCD
}
delay(100); // HX711 - Delays 0.1sec reading on LCD
}
Wireing diagram (This shows an Uno but using a Mega):