Problem receiving digital HIGH/LOW between boards

I'm attempting to send an 'on' signal from my MEGA to my UNO with this code:

on the MEGA:

int outPin = 22;

void setup() {
  // put your setup code here, to run once:
  pinMode(outPin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(outPin, HIGH);
  delay(50);

}

on the UNO;

int inPin = 2;
int redPin = 5;

void setup() {
  // put your setup code here, to run once:
  pinMode(inPin, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(digitalRead(inPin) == HIGH){
    digitalWrite(redPin, HIGH);
  }
  delay(50);
}

I can verify the MEGA pin is set to high, as I can plug it into my breadboard and it lights the LED alone, but does nothing when I attempt to do so through the UNO. What am I doing wrong?

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. Not quote tags. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

Did you connect the grounds of the two boards?

(deleted)

Thank you pert for showing what the tags looked like, I actually couldn't find the dang things!

spycatcher2k, I do indeed have the grounds connected, do they have to be the same ground on each board? or will any two work?

Any ground on either board to any ground on the other board is fine.
All grounds on a board are connected together.

Since I used a PWM from the UNO to the LED, I decided to check the analogWrite function instead of the digitalWrite function, setting the pins to 255, and it worked. Switched to a non-PWM pin and it still worked, but no luck with the digitalWrite function on the new pin.

ShadowfireOmega:
Since I used a PWM from the UNO to the LED, I decided to check the analogWrite function instead of the digitalWrite function, setting the pins to 255, and it worked. Switched to a non-PWM pin and it still worked, but no luck with the digitalWrite function on the new pin.

You're forgetting to pinMode redPin to OUTPUT. analogWrite does that automatically.

void analogWrite(uint8_t pin, int val)
{
	// We need to make sure the PWM output is enabled for those pins
	// that support it, as we turn it off when digitally reading or
	// writing with them.  Also, make sure the pin is in output mode
	// for consistenty with Wiring, which doesn't require a pinMode
	// call for the analog output pins.
	pinMode(pin, OUTPUT);
	if (val == 0)
	{
		digitalWrite(pin, LOW);
	}
	else if (val == 255)
	{
		digitalWrite(pin, HIGH);
	}
	else
	{

I knew it was going to be something simple I overlooked, thank you Jiggly-Ninja!