I am really new to the forum and also to Arduino at all. I am also a beginner in programming.
I have searched the net for solutions, even looked in to the forums, but I could not find anything that would help. I am currently in the planning phase (only the Arduino have arrived, other components are on the way).
What I (will) have: Arduino UNO nRF24L01 2 DC motors 3 Servo motors L293D
I would like to operate 5 motors with the UNO and I want it to communicate via nRF24L01.
As I learned a DC motor needs 2 digital pins (Enable on L293D) and a PWM (to set voltage level for 293D) and the a Servo motor needs 1 PWM (for PWM control).
I plan to supply the motors (and the 293D) from a different battery source.
But this means I will need 4 digital pins (2 DC) and 5 PWM pins (2 DC and 3 PWM).
To use nRF24L01 I would need 5 pins: 9-10-11-12-13 on default. But with the motors set up I will only have 2 digital and 1 PWM pin. This means I will not be able to use nRF24L01 as I seen in examples.
Is it possible to use SPI communication on different pins?
I see that my UNO board have soldered connections for ICSP-s which have MISO, MOSI and SCK pins. Is it possible to use these pins for SPI communication with the nRF24L01?
I understand the define part, but how can I refer to the ICSP pins?
You've done that in your SPI.h -file, you don't have to code it anymore in "your code".. Just use'em..
Someone could explain it more c++-wise but I can't, so in this case I just use libraries written by the others.. :o
What are the required parameters (like CE_PIN)?
All you need to #define are CE and CSN pins and you could do it by
I've used it like in attachment, with external power supply. I have had difficulties to get it work with Arduino board's own 3.3 volt regulator, even with the capacitor..
I have all the hardware (nRF modules, servos etc) and they are working nice. But, I ran out of digital pins, because the SPI uses the 9-10-11-12-13 pins. (I know, that I can put anywhery the CE and CSN, but I want to move the others too.)
I hoped that I can reallocate the CE, CSN, MOSI, MISO, SCLK to the analog outputs. (A4-A0).
I dig through the headers and included libraries a little and I found the definitions in "pins_arduino.h":
But, as I feared, simply changing the numbers to the analog pin numbers did not work. (14-15-16-17-18)
Is it even possible to use the analog pins for SPI? (I know they can be used as digital in- and outputs.) What else shall I modify to make it work?
//Unfortunately, I need 6 PWM pins for servo's, and as far as I know the analog pins can not be used to drive servos not even with the softPWM library.
But, as I feared, simply changing the numbers to the analog pin numbers did not work. (14-15-16-17-18
You have two options: either use the built in SPI module, and the pins dedicated to it, or use "bit-bang" (software) SPI, in which case you can use any pins.
Google "arduino software spi" for several libraries or code examples. It is very simple.