Serial Comm. Problem between Mega and Uno

I am working on my first project that involves serial communication between two Arduino boards. I am using a Mega and Uno. The Mega seems to be sending and receiving correctly but the Uno, which is sending correctly, does not seem to be able to recognize the value that it is receiving from the Mega. The value from the Mega is printing on the Serial Monitor when I have the Uno connected to the USB so I am not sure what is wrong.

Can anyone see what is wrong with my code for the Uno?

test_mega.ino (1.6 KB)

test_uno.ino (1.26 KB)

Why not remove some of the possibility of errors in your code and use a pre-made inter-arduino communication library, like my ICSC - Inter-Chip Serial Communication library? It makes this kind of job a doddle.

@majenko - Does the ICSC library require I add another chip to my circuit or does it work with all Arduinos? Also, do you know if there are any conflicts with other libraries?

It only requires extra chips if you want to link more than 2 arduinos together - i.e., you would need to implement an RS-485 bus. For just 2 Arduinos a straight tx->rx / rx->tx / gnd->gnd wire link is all that's needed. As described here: Arduino Inter-Chip Serial Communication / Wiki / Home

I know of no conflicts with other libraries, as it just operates on serial devices you specify.

@majenko -- Thank you!! Looking at it now.