i have one arduino mega that communicates with one arduino leonardo.
the leonardo controls some motors (mega tell to the leonardo how many step to do... leonardo is a coprocessor for the motor in other words).
for testing i try to send the number 20 from the mega to the leonardo. i sent the number as a sequence of char, with 2 char of haeder so in this case i'm sending 'M>0020' as 6 char (6 byte). leonardo send the status (ready/busy) back to the master through the pin4 (this is to avoid the interrputs in Wire.h that can add delay in the motor code if the master require data to the slave).
communication seems ok, but if i plug power supply (12V) communication crashes. if i reset the mega the leonardo read 11049 (i haven't the board there, could be a different number, but it is always the same), the recives for 5/6 times the correct number 20, then communication crash, and mega crash.
i tried to unplug every motor-related stuff from leonardo, so i have only 4 wire:
- common ground
- the wire for the state (ready/busy) of the slave.
the problems occurs every time i plugged the power supply. sometimes it happens that the problem occurs even without 12v external power (so onlu usb cable that power leonardo) after some time (half an hour)
the 2 arduino boards are linked with a 8m cable (i've used the tester and the cable seems ok, it was a cable for a lan network).