Sending data from a Mega to a Uno running TVout [SOLVED]

I have a Uno running a TVout sketch. I want to send an occasional byte (about 1 per 10 - 30 seconds) to it from a Mega.
The Mega controls real things and I want to sync. what is showing on the TV with it.
I've tried including Wire.h and Softwareserial.h in the TVout sketch and both cause the TVout not to work (black screen). :disappointed_relieved:
The problem seems to be that the TVout uses pins 7, 8, 9, and 11 and these clash with both Wire.h and SoftwareSerial.h. :angry:
I want to avoid using pins 0 and 1, if possible. I don't need wireless, as the two Arduinos are in the same enclosure.
How can I do it?

At that data rate and with the need for TVout to run without disturbance I would use a data / clock pair. Set data to the bit value. Toggle clock. Do it slowly so the Uno can capture the data by polling clock.

[quote author=Coding Badly date=1438831600 link=msg=2345226]
At that data rate and with the need for TVout to run without disturbance I would use a data / clock pair. Set data to the bit value. Toggle clock. Do it slowly so the Uno can capture the data by polling clock.[/quote]
Thanks for that. Not entirely certain what you mean, but it's given me a slightly different idea.
As I only need to send numbers between 0 and 15, I could use 4 digital pins on each to send the data as parallel binary (it's already in that form in the Mega's sketch) with a fifth pin to tell the Uno that the data is ready (a sort of enable pin) and use millis() to poll the 5th pin to see if there is data there to be read. I probably only need to read the 5th pin once a second.

Not entirely certain what you mean...

It is essentially the way SPI works. I just prefer toggling the clock because it makes the code a bit simpler.

I could use 4 digital pins on each to send the data as parallel binary ... with a fifth pin to tell the Uno that the data is ready

Same basic idea. The difference is sending the data in serial or in parallel.

Thanks for that.

You are welcome. If you want details for my proposal just say so.

The Mega controls real things and I want to sync. what is showing on the TV with it.

So, the Uno should be sending data to the Mega, shouldn't it?

The problem seems to be that the TVout uses pins 7, 8, 9, and 11 and these clash with both Wire.h and SoftwareSerial.h.

What Wire.h has to do with sending serial data is a mystery. SoftwareSerial can use pins 7, 8, 9, and 11, but it doesn't have to.

It uses timers and interrupts, which might be the same as the TVout library uses, but that has nothing to with specific pins.

Post a link to the TVout library, and your code, if you want help determining what the conflict is, if there is one.

If SoftwareSerial is clashing with TVout it is possible (only possible :slight_smile: ) that my yet another software serial will work OK.

...R

PaulS:
So, the Uno should be sending data to the Mega, shouldn't it?

No. The mega receives events (hall effect sensors) from the real world. I want the TV display to reflect those events.

PaulS:
What Wire.h has to do with sending serial data is a mystery. SoftwareSerial can use pins 7, 8, 9, and 11, but it doesn't have to.

It uses timers and interrupts, which might be the same as the TVout library uses, but that has nothing to with specific pins.

Post a link to the TVout library, and your code, if you want help determining what the conflict is, if there is one.

The TVout software works OK. As soon as:

#include <SoftwareSerial.h>

is in the code, it compiles and uploads, but I get a blank TV screen.
One thing I noticed is that, during uploading, the Rx and Tx LEDS don't blink!

One thing I noticed is that, during uploading, the Rx and Tx LEDS don't blink!

That would mean that no serial communication is happening, which would generate an error. You'd certainly have a different complaint if that was the case.

SoftwareSerial uses interrupts. If you include that header file AND DO NOTHING ELSE with it, and the code stops working, it means that SoftwareSerial has registered a different interrupt handler that is making TVout not work.

The only real solution is another Mega, so you don't need to use SoftwareSerial.

The Rx & Tx LEDs will only blink during a transfer thru the USB port. The 16U2 controls the LEDs.

I've now found that Serial.print also stops the TVout from working, so I'm flipping the LED on pin 13 to show that the incoming data is being read. One read every 1 or 2 seconds is all I need. It's not time critical.