Fixing Loud Noise Issue with L298N Motor Driver and Arduino Uno for XY Laser Rig

Hi. I am trying to fix a problem, where when using the L298N motor driver with Arduino Uno makes a horrible loud noise. I have a laser burner XY axis rig which when operated using the built-in board does not make any strange noises. The above issue occurs when I try to connect its stepper motors via my combination of Arduino UNO and two L298N motor drivers. For details please see the images and diagram. Any suggestions on how to fix this, This is the code I'm using // Define motor control pins const int motor1DirPin = 8; const int motor1StepPin = 9; const int motor2DirPin = 10; const int motor2StepPin = 11; const int laserPin = 12; void setup() { // Set motor pins as output pinMode(motor1DirPin, OUTPUT); pinMode(motor1StepPin, OUTPUT); pinMode(motor2DirPin, OUTPUT); pinMode(motor2StepPin, OUTPUT); pinMode(laserPin, OUTPUT); // Initialize laser as off digitalWrite(laserPin, LOW); } void loop() { // Example movement and laser control sequence // Move in X direction moveStepper(motor1DirPin, motor1StepPin, true, 100); // Move forward 100 steps delay(1000); // Move in Y direction moveStepper(motor2DirPin, motor2StepPin, true, 100); // Move forward 100 steps delay(1000); // Turn on the laser digitalWrite(laserPin, HIGH); delay(2000); // Move back in X direction moveStepper(motor1DirPin, motor1StepPin, false, 100); // Move backward 100 steps delay(1000); // Move back in Y direction moveStepper(motor2DirPin, motor2StepPin, false, 100); // Move backward 100 steps delay(1000); // Turn off the laser digitalWrite(laserPin, LOW); delay(2000); } // Function to move stepper motor void moveStepper(int dirPin, int stepPin, bool dir, int steps) { digitalWrite(dirPin, dir); // Set direction for (int i = 0; i < steps; i++) { digitalWrite(stepPin, HIGH); delayMicroseconds(500); // Adjust delay for speed control digitalWrite(stepPin, LOW); delayMicroseconds(500); } }
attachment 0
attachment 1
attachment 2
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server