NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » RC Car HELP!

February 08, 2013
by higgy333
higgy333's Avatar

I have managed to get the circuit built. Car goes forward and backward along with side to side. The web server works on the computer and my iphone. We go to run the pyCar.py and all it does it change the cursor and when I click somewhere it takes a screenshot of the window I clicked.

Here is the pyCar.py code. (my_pipe is on the Desktop)

        import serial
        #screen size 320x480

        maxX = float(480)
        maxY = float(550)
        s = serial.Serial("/dev/ttyUSB0", 115200)

        def transformPoint(x,y):
            scaledx = (float(x)/maxX)*255 
            scaledy = (float(y)/maxY)*255 
            (left,right) = (capValue(scaledy + scaledx), capValue(scaledy - scaledx))
            return (left,right)

        def capValue(val):
            if val > 255:
                val = 255
            elif val < -255:
                val = -255
            return val

        def handleNewPoint(command):
            try:
                (x,y) = command.split(",")
                (left,right) = transformPoint(x,y)
                s.write("L " + str(int(left)) + "\n")
                s.write("R " + str(int(right)) + "\n")
                print "L " + str(int(left)) + " R " + str(int(right))
            except:
                print "Error occurred. Ignore and move on"

    while(True):
        tePipe = open('/Desktop/my_pipe', 'r')
        handleNewPoint(tePipe.read());
        tePipe.close()

If anyone could tell me what is going on that would be great! If I run in terminal it brings up a blank terminal with the symptoms above. We have managed to wire up the car and figure out how to make it turn and go forward and backward. It will only go forward unless we add the back control wire. The server works. I can get it to display car.php on my iphone and tell me the vectors.

February 18, 2013
by higgy333
higgy333's Avatar

Still haven't gotten any farther. Any help?

February 18, 2013
by higgy333
higgy333's Avatar

We are running this off of Ubuntu 12.04 and there is connection between my phone and the computer through the webserver but there is no connection between the computer and the rc car even though we have loaded the code onto the chip to where it should.

Post a Reply

Please log in to post a reply.

Did you know that Pulse Width Modulation (PWM) can be used to control the speed of a motor digitally? Learn more...