The fact is, when I switch off the relay, after a few cycles the data flowing in the serial windows become corrupted: some missing chars, unreadeable chars, ecc.
tried to run also the relay at 3.3v but it's the same story.
The program continues well. but Serial data are corrupted (or stop flowing)
I would don't mind, but I need to interface also a RTC ds1307 clock, and I encountered a couple of time that the oscillator of the clock stopped at relay switching off.
So this become very important, as I use the clock to pilote the relay, and I cannot permit myself that it stops responding..
Does that simplified code (once you have corrected the error with it) manifest the problem with Serial output that you describe ?
Does the problem still persist if there is nothing connected to the relay pin ?
oh, I forgot to write that if I disconnect the control relay pin the problem seems to disappear.
I can run longer the prog without any problem.
Is it possible that arduino sends raw data so serial monitor, and serial miss some bits and data become corrupted for this?
I mean... arduino sends some like 01001111 (8bits) and serial read 0100111 (7bits)
so all the next chars will be corrupted because serial missed 1 bit, and assigns the first bit of all the next chars to the previsious one.. wrong?
The serial output is sent and received byte by byte so there is no chance that sometimes 7 bits are used and at other times 8 bits are used. Is the relay being used to switch anything ? If so, what happens if you disconnect the load ?