The motors do not work; they don't spin although I hear a hum or beep sound. When I give it a spin with my hand, they move. I have tested the motors individually by connecting them to the power source. And also one thing I would like to add, when I disconnect the USB from the Arduino Uno, they don't make any hum or beep sound nor do they move when i give it a little spin as if I haven't uploaded the code to the Arduino at all.
What is the rated voltage and the stall current specifications of the motors? Please post a data sheet for the motors.
The L293 driver is ancient and inefficient tech. They drop 2V to over 4V of the motor supply voltage (more voltage drop for higher current) and dissipate that power as heat. The L293 is only good for 600mA.
That is over 4 times the current that the L293 is capable of supplying. Do you have a Digital Multi Meter or Volt meter? What is the voltage across the motor when you try to run it?
Are you using an L293D or are you using an Adafruit Motor Shield? Because the library you have is the VERY old one for the Adafruit motor shield. There is a newer version of that library if you are using a motor shield purchased anytime in the last 5-7 years.
And if you do have a motor shield, take a look at the example. You are missing a lot of important code necessary to initiate connection with the motor shield.
If you are truly using an L293D, then I would suggest you look at an example of how you control 2 DC motors with one L293D. If you want to control 4, you would need two of them. Because each motor takes up 2 pin on the L293D.
I highly recommend you get a driver that has MOSFET outputs. The L293D is not a good part to use especially with batteries. It in itself consumes about 35mA. It has a bipolar darling ton output on each motor lead which will drop about 1.5V (0.7V * 2 leads). That works out to your 6V voltage from the fresh batteries will give you about 3 volts on the motors so do not expect much performance. You will also have a voltage drop from the batterer because of there internal resistance. You need a heat sink with it because of all of your power is being burnt up as heat. If my memory is correct this was first introduced as a H-Bridge for automotive mirror motors.
I found this on the internet, it sums it up nicely: " The TB6612FNG is smaller than the L298N, and doesn't require a heat sink. It also features a much higher efficiency at over 90% versus 40-70% for the L298N, and a low-current standby mode that the L' lacks."
Have you measured your batteries? Each motor wants 6vdc. Only if your 4x1.5AA are fresh will they all work (for a couple minutes). Add a fifth (5x1.5 = 7.5) in series, or try a 6vdc mains power supply.
What do you mean "4 octopus"? Dou mean you are doubling up connecting two motors to each of the outputs? That still doesn't make any sense. That would means you would only have two motors to control. Not 4.
Plus, your code is not going to work with your controller....ever. It's using the wrong library and it's not even using it correctly.
So I connected 4x(3.7V 1300 mAh) batteries to l293D (which is connected to four dc gear motors) and there was smoke coming from l293D. If I try to replace one of the batteries with a 1.5V battery, the motors won't work. What should I do?