deefunkt
Posts: 9
Joined: Fri Mar 15, 2013 11:19 pm

RC car stuffing up!

Sat May 18, 2013 1:41 am

Hey guys
So I've been trying to make an automated RC car by using an old one I had lying around. Problems have arisen.
(I had a much nicer introduction to my question, but when I clicked submit, internal server error ---> lost my whole damn post.)
I'm using the Adafruit prototyping plate, and the L293D IC.

My setup is as follows:
Image

The green wire is +power from batteries, going into VS of IC
The brownish wire is ground, or -power from battery, and goes into 1 of 4 ground terminals of IC
The white and yellow wires are wires from the motor, and go into outputs of IC

My code is as follows:

Code: Select all

import RPi.GPIO as io
import time
io.setmode(io.BCM)

in1=17
in2=4

io.setup(in1, io.OUT)
io.setup(in2, io.OUT)

def clockwise():
    io.output(in1, True)
    io.output(in2, False)

def counter_clockwise():
    io.output(in1, False)
    io.output(in2, True)

clockwise()

while True:
    cmd = raw_input("Enter 'f' or 'r' for forward or reverse respectively:  ")
    direction = cmd[0]
    if direction == "f":
        clockwise()
        time.sleep(1)
    else:
        counter_clockwise()
        time.sleep(1)
    if KeyboardInterrupt:
        io.cleanup()
When I run it with the command 'f', nothing happens at all.
When I press 'r', I get the error:

Code: Select all

Enter 'f' or 'r' for forward or reverse respectively:  f
Enter 'f' or 'r' for forward or reverse respectively:  r
Traceback (most recent call last):
  File "car.py", line 28, in <module>
    counter_clockwise()
  File "car.py", line 16, in counter_clockwise
    io.output(in1, False)
RPi.GPIO.WrongDirectionException: The GPIO channel has not been set up as an OUTPUT
What is wrong?! I've checked my connections, and my code, what am I missing?

Return to “Automation, sensing and robotics”