The master arduino is connected to the computer via USB and slave arduino is only connected to master (by wiring up common 5V and GND).The rotary encoder is wired only to the mega.I want to send it's position from Arduino Mega to Arduino Mini serially via SPI communication.
While using SPI communication to communicate between Master (Arduino Mega 2560) and Slave (Arduino Mini), the following are the two concerns:
- Do I need to write programming code for Master and Slave in two different files or I can combine those in one file and upload the code in the master arduino??
- How does the computer know which is master arduino and which is slave?? Based on that question, what indicators do I have to include in the programming code to tell the IDE that this arduino needs to be master??
Is it possible to accomplish the above task in different manner?? If so, than please guide me to the appropriate post or arduino library.
Many Thanks,
Shivang