0

Sorry if the title is confusing, along with my question below. I might have to break this into multiple questions.

I'm quite new to this.

I am trying to control a cheap RC car with my Pi via my laptop. I have the GPIO correctly wired to the controller inputs and can make the car turn left, right, forward, reverse by turning the pins on and off manually . But I want to do this as I was able to before I rewired the controller only using keyboard inputs.

Someone told me today it may not be possible to do exactly what I am trying to do unless I use Pulse Width Modulation (which I am not too familiar with yet). Also I have seen a similar project that apparently needed a relay module to get it working (can anyone affirm this?)

I want my program to continuously loop and if the forward/reverse, left/right keys are pressed, change the GPIO.ouput's accordingly. Also, if only one or no directional key is pressed, have the GPIO.output's be in their neutral states.

I have read some similar questions including this one Controlling a common RC car

and tried some different approaches but could use a few tips. Money is tight and I don't want to go and buy hardware if I don't have to. Can anyone help provide some direction?

Thank you.

1 Answers1

0

Ok, I've got this sorted out. Here is the working code: https://github.com/166inter/raspberryPorsche/blob/master/Autonomous1.2.1.py

It uses threading and a queue that, when empty, returns to the default state (straight steering, no forward or reverse). Else, the next command will be taken from the queue.