I would recommend that you use a Opto Coupler. An Opto coupler consist of a LED (Light Emitting Diode) and a Photo sensitive transistor.
That will create a safety isolation between your motor that creates nasty electrical spikes and your precious Raspberry Pi.
Take a look at the Youtube video for more detailed info https://www.youtube.com/watch?v=pYENAGK8qH4
The 50 mA limit is for the GPIO.
The 3V3 pins are not GPIO.
You can draw as much current from the 3V3 pins as is available from the power supply. If you attempt to draw more current than is available the Pi will reboot.
There is more than one type of motor driver board using the L298N.
The typical board has two voltage inputs and a common ground.
One voltage input is to drive the motors. The other voltage input is to provide logic power to the module.
Typically the board has a jumper which can be fitted to supply logic power from the motor supply. If that is fitted DO NOT ...
6V motors usually work fine with 5V (other than the fact that they run at 80%..85% of it max speed). However, powering a motor from the Pi is only possible for very small motors, which have stall current that the Pi can provide without a significant voltage drop. Even toy motors are often rated for 2A stall current or more, which can easily reboot the Pi ...
From your description the batteries can not supply enough power for a
sustained period. They are drained after four seconds of use until you give them a period of rest when they recover enough for a few more seconds.
You need more powerful batteries or smaller motors.
You need to do some more research.
I suggest you start with something simpler! Preferably light a few LEDs.
You use GPIO.setmode(GPIO.BOARD) BUT then use BCM numbering.
You DO NOT have a Gnd connection between the devices - this is ABSOLUTELY essential for all circuits.
You DO NOT have proper connections to the device. Sticking pins through the holes is not ...
One problem is the way you are using pigpio.
You are using alerts (GOOD) which supply an ordered sequence of timed GPIO events. You are reading the current level of a GPIO within the callback (VERY BAD). The event which triggered the callback may have happened several milliseconds before and will not necessarily be consistent with the current state of the ...
Just a couple of suggestions:
I use Lipo power bank to power 3+ sg90/mg995/mg996 servos, and dc motors.
I use SIM7600's using USB UART ports not sharing with Rpi GPIOs handling servos.
I use Rpi3B+, Rpi4B as development machine, and RpiZ/W on the drone, this way saves much prototyping time.
Using 16 Channel PWM/servo module is an overkill.
The error message reads
RuntimeError: The GPIO channel has not been set up as an OUTPUT*
Notice how for the ENA1 pin you make a call to GPIO.setup() but don't do so for the other pins you are using. You need to set the mode of a pin (to output, in this case) before you attempt to use it.
So you might try something like this:
The circuit from the video in the above YouTube link shows how to use the RPi to turn the motor on or off. To detect whether or not the motor is running, the circuit needs to be modified (see the schematic/diagram below). You won't be using the "here > > > > > >" part of the yellow wire (as seen in your question) because that ...
Bouncing means you have extra edges in the signal, so the error you get from it can only be a higher count, not lower.
De-bouncing means your software ignores the edges which come faster than expected, so it can remove those extra edges, or, if the de-bounce time is too high, ignore legitimate edges, leading to a lower count. As far as I can tell there is no ...