I2C or Serial communication between two Arduinos, with more than one data value

Hi everyone.

I'm currently adding Arduino and nRF24l01 modules to a forklift model that I have. It uses one motor for driving, and a second motor for lifting/lowering the pallet fork. I also have a steering servo.

But there is one minor problem to this build, which is that the Arduino Pro Mini (as many other Arduino models) only have 6 PWM pins. I would need 3 PWM pins for the NRF module, 3 for the motor driver (remember, two motors) and 1 PWM pin for the steering servo, which makes a total of 7 PWM pins. Thats where my problem starts... I need one extra PWM pin, or do I? I'm using a TB6612FNG motor driver, which defines the pins like this:

#define AIN1 2
#define BIN1 7
#define AIN2 4
#define BIN2 8
#define PWMA 5
#define PWMB 6
#define STBY 9

The STBY pin is described like this on sparkfuns page about the motor driver: Allows the H-bridges to work when high (has a pulldown resistor so it must actively pulled high), and I have just assumed that this needs to be a PWM pin.

So first question, am I wrong? Maybe I could use another pin for the STBY and then it would work perfectly.

Second thought: I also want to add lights, and maybe a horn to the model, so I've been thinking of adding a second Arduino anyways (because I'd need more pins). I have looked up the I2C protocol and the Software serial library, but the only problem is that I need to send a whole bunch of data values, not just one at a time. I would guess that there is a way to send multiple data values (or an array), but I have not yet figured it out. Could anyone please tell me how this can, and should be done?

Thanks in advance.
Marcus

I would need 3 PWM pins for the NRF module

Why? The NRF radios do not need PWM pins.

Servos don't need PWM pins, either.

You need PWM pins only to control the speed of the motors, so only two PWM pins are needed.

This Simple nRF24L01+ Tutorial may be helpful. I use the technique in the second example for controlling a model train.

...R

PaulS:
Why? The NRF radios do not need PWM pins.

Servos don't need PWM pins, either.

You need PWM pins only to control the speed of the motors, so only two PWM pins are needed.

Oh, lol. Where did that come from. Must have thought it because the servo pin was 9 in a demo sketch, and I've been using that pin ever since, haha. Anyways, thanks a lot for the clarification.

And for the I2C/Serial part, anyone got some input there? Would need that part for adding light etc, as I'm running short on pins...

If you need to send data by Serial have a look at Serial Input Basics. The parse example illustrates how multiple values can be dealt with.

...R

Robin2:
If you need to send data by Serial have a look at Serial Input Basics. The parse example illustrates how multiple values can be dealt with.

...R

Great Robin, thanks a lot! I'll try it out as soon as time allows it...