Connecting two AtMega328P

I am making a physical baseball game, with players running to bases around the field depending on how great a shot is. I've used up all of my GPIO pins on my ATMega328p, and was wondering how i can connect two atmegas together. I need to send the data for the shotquality to the slave, which then uses that data to determine how far a stepper motor should step.
I have 4 steppers, one to move a player between each base, with each hooked to a driver for controlling them.
Since im not in need of fast data transfer between each device, im not sure whether i should use I2C or SPI, and i haven't quite figured out how to use the different techniques.
This is one of the first bigger projects i have made, and any help would be great.

Welcome to the forum

Have you used all of the analogue input pins ?

You can't use either, if you have already used all the GPIOs, since I2C and SPI use GPIO pins.

Please post a complete wiring diagram (hand draw is fine), with all pins and connections clearly labeled.

1 Like

You don't mention how you have used the GPIOs. Some are for the steppers but for other stuff you can consider using shift registers or I2C/SPI port expanders for digital IO and analogue multiplexers for analogue inputs.

It will more than likely be easier than creating a solid communication protocol between two 328P processors.

I’m assuming the processors are separated by some distance. Have you considered using CAN (Controller Area Network)? It’s well-suited for communication over longer distances and is designed to handle robust and reliable communication between processors in complex systems.

Move your code to a board with more I/O pins such as a MEGA board. It is easier to use a Clydesdale than harness a bunch of Shetland ponies together.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.