-1

I know I asked this question before, but this time I will give a more clearer description. I have been using the raspberry pi for approximately 6 months now. I am making a very simple robot car that includes a motor and ultrasonic sensor circuit. The ultrasonic sensor works perfectly but the motors aren't spinning with my circuit and programs. Please help:

Info and details: I am using a 9v battery, and l298n, 2 DC Motors and the raspberry pi and some wires for the motor circuit. You can see the circuit in the picture below made using the app fritzing: enter image description here

Then I programmed the circuit using the raspberry pi using python and the RPi.GPIO library / module. The code is below:

# importing all modules
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)

# Setting up gpio pins for output
GPIO.setup(37, GPIO.OUT)
GPIO.setup(35, GPIO.OUT)
GPIO.setup(33, GPIO.OUT)
GPIO.setup(31, GPIO.OUT)

# Moving the car/ rotating the motor
# This part just moves the car front for 2 secs then back for 2 secs

GPIO.output(37, True)
GPIO.output(33, True)
time.sleep(2)
GPIO.output(37, False)
GPIO.output(33, False)
time.sleep(2)
GPIO.output(35, True)
GPIO.output(31, True)
time.sleep(2)
GPIO.output(35, False)
GPIO.output(31, False)

# Cleaning up
GPIO.cleanup()

There are no errors in the code when I run it (If there are in the code above, then that's probably true because I didn't copy and paste the code, I just wrote it here, so there might be a typo or something). The program just doesn't do anything. I ran it on idle in the raspberry pi. Please help, any good help will be useful thank you! Thank you as it means a lot!!

  • I have told you what is wrong with the code. I suggest you read my comment on your previous question. – joan Apr 14 at 17:49
  • Please take the short Tour and visit the Help Center to get an idea how things work here. – Ingo Apr 14 at 18:51
0

I know I asked this question before, but this time I will give a more clearer description.

I know I answered this question before, but this time I will give a more clearer description link.

Robot buggy - Assembling the motors and board - projects.raspberrypi.org

robot buggy

I have also assembled a 16450 power bank for my L298N robot buggy

power bank 16450

  • Yeah, I would have also tried to improve your last answer although I could see you put a lot of effort into answering my question! Thank you and your website gave a lot of information! – Hritik RC Apr 16 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.