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.
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. https://www.aliexpress.com/item/2022057125.html
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?
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.
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: https://learn.adafruit.com/adafruit-motor-shield
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.
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
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
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 ...
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 ...
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.
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.
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.
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.