Using a motor controller and a 2.4GHz transceiver but running out of pins

Hi Guys,

I'm relatively new to arduino and I've hit a bit of a roadblock in my current project, where I'm building a remote controlled truck with two Arduino unos. One of the Arduinos will have a 2.4GHz transceiver on it, along with joysticks and buttons. This Arduino will act as a controller. My second Arduino will be used to actually drive motors and servos based on the outputs of the other Arduino. On this Arduino I have a motor controller (link) and a 2.4GHz transceiver (link). My problem is that both of these components share common pins. According to the Adafruit FAQ page for their motor shield, pins 4-9 and 11-12 are in use.

The transceiver that I am using also uses pins 6,7,9 which conflicts with the motor controller (right?). I just wanted to know if I could just 'reallocate' these pins in software or do some other fix so I could keep using both components.

Cheers for any help.

Welcome to the forum.

I think that is not possible.
The 2.4GHz transceiver uses the SPI bus, and those pins are also used by the Motor Shield.
The Motor Shield might be the first module that Adafruit designed, it is for small 9V or 12V toy motors. Today, there are better solutions.

The Motor Shield has a connector for servo motors, but those are directly connected to pins of the Arduino Uno. The Arduino Uno generates the servo signals.

Did you pay 10 Aussie Dollars for a clone of the Motor Shield ? They bought it for 2 dollars or less and then sold it to you for 10 dollars.

What kind of motors do you have ? Voltage, current, links to the motors, and so on.

Yeah theres definitely cheaper options out there for the motor shield, but I couldn't really risk having to wait ages for shipping at the moment. Currently haven't found motors for the actual project as the car component has to be designed first but was planning on maybe using 2x 12v motors and 2x 9G servos. Do you know of any way I can control the motors using a controller of some sort without using the SPI bus?

Those servo motors might require a peak current of more than 500mA. You need enough power for that.

First, try to find a motor. If that motor has a "stall current" of 5A, than you need a motor driver of 5A.
This is Adafruit's new Motor Shield:
This is a smaller module:
Here is an overview, just to show what modern motor drivers look like:
Sometimes, all you need is a TB6612:

Please don't buy this: It makes me :cry: or :face_vomiting:

I am not familiar with your shields etc but the SPI bus supports an almost unlimited units, each unit needs a CS (chip select) pin that is activated when talking to it. MOSI, MISO, and SCK are connected to the appropriate pins on each shield. Your software needs to select which unit it is talking to. Also SPI is a bi-directional communication bus, as you clock data out you are clocking data in. You cannot read it unless you send something.

If I were to use these servos (link), which supposedly have a working current of less than 500mA would that be ok. I could also use an external power supply (up to 13V is allowed) which I could then use to supply current to the servo and then just connect to arduino for signal (is this correct?). If so, I wouldn't need to connect servos to the motor controller and I could just connect the motors to it instead. Even if I did that, would there be any way of still incorporating my 2.4GHz transceiver module with that existing motor controller without running out of pins. Or should I simply just get a smaller motor controller that controls two motors and hopefully have enough pins for the transceiver.

Thanks for your help so far

A "working current" is a made up term. They could require a peak current of a little more than 500 mA.

The 5V pin of a Arduino board is not strong enough for a servo motor.
If you use an external power supply, then you could add a DC/DC-converter to make 5V for the Arduino board and the servo motor.
It will be helpful for us (and for you) if you draw a schematic that shows the wiring.

The "Motor Shield" can not be used if you want to use the SPI bus.
I'm talking about this ancient motorshield:
It does not use the SPI bus, it uses the pins of the SPI bus.

That motor shield does not use pin 2 and 13 and not the analog pins. The analog pins can be used as digital pins and also the I2C bus is still available. With that shield you can add a sensor or a few leds, but it can not be used together with the SPI bus.


I've done a bit more reading and it looks like the motor shield doesn't use as many pins as I thought; however, it still uses some pins of the SPI bus. Here are the connections.

So to still use my 2.4GHz transceivers, Im thinking of looking for a smaller motor controller that uses less pins that will drive 2 motors and then I can get the power for the servos from the batteries. I'll probably also use the batteries to power the arduino. If I use a 12v power source (8xAA batteries in series), I could use a voltage divider to run 7V to the arduino and 4V to the servos. The servos could be in parallel just so I get the voltage (not sure If ill get enough current though). My electrical circuit knowledge isn't too good so sorry in advance.

Thanks for the help

A Arduino Uno has pin 0 and 1 for the serial communication with the computer.
You found that the Motor Shield uses: 3,4,5,6,7,8,9,10,11,12.
That means that pin 2 and 13 and the analog pins are still available.
I think that I already wrote that :yawning_face:
You didn't have to search for it. Adafruit designed that Motor Shield and they also provide the schematic and everything.
I think that I already gave a link to Adafruit about that Motor Shield :yawning_face:

You can not use a voltage divider for a servo motor.
A voltage divider with resistors is for 0.1mA or so.
If you want to power the servo motors from 12V, then you need a DC/DC-converter.
I think that I ... :yawning_face:

You can not just buy a driver module. It starts with the motors. If you buy a motor that has a stall current of 5A and the driver module is only for 1A, then the driver module might get damaged.
I think ... :yawning_face:

The SPI bus is (alternate labels) pins 10 (SS/CS), 11 (COPI/MOSI), 12 (CIPO/MISO), 13 (CLK/SCLK), and any more select lines for devices on the bus.

Try switching transceiver to A0, A1, A2 since the analog pins also work as digital pins.

I find that the bigger the PCB, the fewer fit on a blank, the higher the price.
So I buy modules instead of shields and DuPont cables with sleeve ends for pins.

Next step, build standalone AVR chip end products. An ATmega328P-PU was about $2.50 if that in 2019.
Breadboard Duinos and custom software.

Ok, thanks for the information. I'll have a further look into it all.

This is probably a dumb question, but how could i switch the transceiver to the analog pins?

Change the pin numbers in a copy of a working transceiver sketch and see if it still works when you move th jumpers as well.

If all this code is a mystery to you, you're in over you head.

Yeah I know that I can set the radio to use various pins for CE and CSN by changing the values in:

RF24 radio(9,10);

to other pins but I can't think of way in software to change the other pins for either the motor controller or the transceiver since both devices use the SPI bus.

The key word there is bus

Within reason you can connect as many devices as you like to it but only the device that you address will receive the data on the bus

Please, gilshultz, GoForSmoke, and UKHeliBob, please stop doing that. You are only causing confusion. Investigate the Adafruit Motor Shield. Buy a clone to test it. Look at the schematic. See for yourself how the pins are used. Look at RF24 libraries and how almost everyone uses hardware SPI. At least give links to how to switch to other pins.

hicksyy1, I'm sorry, but the others don't know what they are talking about. Most of time, the majority on this forum agree on something.

I said "No" to keep you out of trouble, but GoForSmoke is not wrong.

It is possible to avoid the hardware SPI bus for the RF24 (nRF24L01+) and use a software implementation that can be used on any pins. Someone has it working here.
But I'm afraid that is might cause new troubles and I don't like that Motor Shield anyway.

So if you really want to use both, then read this about using software SPI on other pins (you can use A0 ... A5):

I'm sorry if I have upset you, but I was responding explicitly to

so what is wrong with my reply ?

Okay thanks, I'll have a further look into it all, and weigh up some other options. Big thanks for your time :slight_smile:

hicksyy1 made a very small mistake as a new user.

I think I already explained that when I wrote:

The Motor Shield is one of the first things that Adafruit designed when they started the company. It is no longer up to date.
I think that I gave enough links, so with a click on a link you find the schematic at Github:

The MISO and MOSI pins are used for a motor pwm signal and a latch signal for the 595 shift register.

I'm spending more time just finding out what the OP knows and trying to correct simple misconceptions.

I don't like that motor shield either, or the site it's shown on. There's links for a user manual and a datasheet, both of which give the manual with minimal user info.