## Help: Using GPIO to control a remote control car

winkleink
Forum Moderator
Posts: 288
Joined: Mon Nov 07, 2011 9:12 am
Location: UK
Contact: Website

### Help: Using GPIO to control a remote control car

I'm looking to use the GPIO pins to control a remote control car by activating the switches in the controller using a transistor as a switch.
The controller is powered by 2 AA batteries (3V) and the pins for the different controls are tied high normally. When the switch is activated the pin is tied to Zero (-)

I was considering the following attached circuit and before I wire it all up I thought it might be a good idea to make sure I have it right. I have basic-ish knowledge of electronics and don't want to damage my Raspberry Pi
g3075.png (38.69 KiB) Viewed 2795 times
In my head this ties the pin to 3V until a Base current is applied.
When the current is applied the circuit effectively become 3V - R1 - Pin - Q1 (0Ohm) - OV, so Pin is tied to 0V.

Also, any suggestions for R1 and R2

My Guess
R1 - 1KOhm
R2 - 10KOhm (Base)

I checked the current across the switches (so inline) and it was reading 0.1mA. With a 10KOhm resistor and 3.3V from the GPIO I would be providing 0.33mA (I think), so way more than enough to saturate the Base.

Any and all tips appreciated. You could save a Raspberrp Pi from being being fried...

Thanks,
Albert.

Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

### Re: Help: Using GPIO to control a remote control car

Yep, looks all good.
I have basic-ish knowledge of electronics and don't want to damage my Raspberry Pi
You have done all the right things, measured the correct currents and calculated all the values fine.
I have seen posted data much, much worse then this.
In fact if everybody put as much work in us 'experts' wouls have only a fraction of corrections to do.

One final point: you might want to add a 10K resistor between base and ground.
That way the circuit is in a defined state during booting when some GPIOs are set to input mode.

winkleink
Forum Moderator
Posts: 288
Joined: Mon Nov 07, 2011 9:12 am
Location: UK
Contact: Website

### Re: Help: Using GPIO to control a remote control car

Gert van Loo wrote:Yep, looks all good.
I have basic-ish knowledge of electronics and don't want to damage my Raspberry Pi
You have done all the right things, measured the correct currents and calculated all the values fine.
I have seen posted data much, much worse then this.
In fact if everybody put as much work in us 'experts' wouls have only a fraction of corrections to do.

One final point: you might want to add a 10K resistor between base and ground.
That way the circuit is in a defined state during booting when some GPIOs are set to input mode.
Gert, thank you. My head is swelling getting a comment like that from the Gertboard man.
Also, thanks for the pointer on the additional resistor.

The plan is to have this working for the Egham/Staines Raspberry Jam on Sunday so your extremely prompt reply id hugely appreciated.

Albert.

winkleink
Forum Moderator
Posts: 288
Joined: Mon Nov 07, 2011 9:12 am
Location: UK
Contact: Website

### Re: Help: Using GPIO to control a remote control car

Yeah.

I built the circuit and it worked. Not yet with a Raspberry Pi. As the Raspberry Pi is the newest piece for me I wanted to make sure all the other bits were sorted so that when I mess up on the Raspberry Pi piece I know it is only that bit I have to troubleshoot rather than thinking maybe the circuit was wrong.

I tested using an Arduino and successfully has the car going forward, backwards and turning left and right.

Tomorrow night is the Raspberry Pi bit...

Burngate
Posts: 6347
Joined: Thu Sep 29, 2011 4:34 pm
Contact: Website

### Re: Help: Using GPIO to control a remote control car

Looking forward to seeing it working, Sunday!

winkleink
Forum Moderator
Posts: 288
Joined: Mon Nov 07, 2011 9:12 am
Location: UK
Contact: Website

### Re: Help: Using GPIO to control a remote control car

Burngate wrote:Looking forward to seeing it working, Sunday!
So, am I.