I want to run DC motors with raspberry pi 3 using relay can any one please give me the code ?
I want to run DC motors with raspberry pi 3 using relay can any one please give me the code ?
The code looks like it is for a full H bridge driver, not a couple of relays. The code is using 4 outputs in total and you only have two connected in your diagram
Also in the diagram it looks like you have pin 8 connected to ground of the relay board. It should be pin6, 9 or 14.
Lastly it looks like you're powering the relay board from the 5V of the PI (Pin 2). Is this just for the opto isolators or is it powering the relays as well, if so this may be too much noise / load for the PI. I can't see what is behind the wires to be sure.
The basic code methodology looks correct as a basis to work from, but you need to change the various functions (Forward, Back, Left, Right, Pivot etc) to drive the relays instead of the H Bridge seems it is coded for
If you can show how your wiring the motor to the relays, we can help you move forward.
The code looks like it is for a full H bridge driver, not a couple of relays. The code is using 4 outputs in total and you only have two connected in your diagram
Also in the diagram it looks like you have pin 8 connected to ground of the relay board. It should be pin6, 9 or 14.
Lastly it looks like you're powering the relay board from the 5V of the PI (Pin 2). Is this just for the opto isolators or is it powering the relays as well, if so this may be too much noise / load for the PI. I can't see what is behind the wires to be sure.
The basic code methodology looks correct as a basis to work from, but you need to change the various functions (Forward, Back, Left, Right, Pivot etc) to drive the relays instead of the H Bridge seems it is coded for
If you can show how your wiring the motor to the relays, we can help you move forward.