ATtiny45 rf 434 SIMPLE transmission?

Hi,

I’m using an RF 434 transmitter and receiver modules for the simple purpose of turning an LED on or off.
All that I want this circuit to do is that when the transmitter transmits the character ‘b’ (or any character), the receiver will receive this character and turn a pin ON.

I wrote a really simple code (I expected to receive noise. I wasn’t trying to use this rf module to send real data, just using it for a simple and secure way of transmission)

Transmitter:

#include <SoftwareSerial.h>

SoftwareSerial mySerial (A1,1); //RX, TX

int notifPin = 0;

void setup()
{
	mySerial.begin(2400);	//RF 434 uses 2400
	pinMode(notifPin, OUTPUT);
}

void loop()
{
	mySerial.println('b');
	digitalWrite(notifPin, HIGH);
	delay(1000);	//buffer
	digitalWrite(notifPin, LOW);
}

Receiver:

#include <SoftwareSerial.h>

SoftwareSerial mySerial (0,1); //RX, TX

int activePin = 2;

void setup()
{
	mySerial.begin(2400);	//RF 434 uses 2400
	pinMode(activePin, OUTPUT);
	digitalWrite(activePin, LOW);
}

void loop()
{
	int data = mySerial.read();
	if(data == 'b')
	{
		digitalWrite(activePin, HIGH);	//turn on relay and led
		delay(5000);	//buffer
	}
	else
	{
		digitalWrite(activePin, LOW);
	}
}

When I ran this code the receiver sometimes randomly activated even when the transmitter was not transmitting (I was receiving some random 'b’s from somewhere) and sometimes when the transmitter was on, the receiver did not activate.

I understand that I would need some sort of filtering or a method of checking, but so far my options are limited on an ATTiny. VirtualWire and RadioHead are not compatible with the ATTiny45.

I looked at KDarrah’s tutorial on this rf transmitter, but I dismissed it because I was not trying to receive data and print it, just receive it and do something based on that data.

Does anyone know a code that would perform this simple task (turn on a pin when the correct byte is received, and ignore noise)?

Thank you so much!
Attached are the circuit diagrams if they might help.

RXbreadboard.pdf (182 KB)

TXbreadboard.pdf (144 KB)

TXschema.pdf (56.9 KB)

RXschema.pdf (80.9 KB)

Ah okay

After a long while of debugging I got this code to work wired
That means that instead of connecting to the modules I connected these two microcontrollers directly to each other.

Transmitter:

#include <SoftwareSerial.h>

SoftwareSerial mySerial (A1,1); //RX, TX

int notifPin = 0;

void setup()
{
	mySerial.begin(2400);	//RF 434 uses 2400
	pinMode(notifPin, OUTPUT);
}

void loop()
{
	digitalWrite(notifPin, HIGH);
	mySerial.println("BANGBANG");
	delay(100);
	digitalWrite(notifPin, LOW);

	delay(900);	//buffer
}

Receiver:

#include <SoftwareSerial.h>

SoftwareSerial mySerial (0,1); //RX, TX

int activePin = 2;

char inData[20]; // Allocate some space for the string
char inChar=-1; // Where to store the character read
byte index = 0; // Index into array; where to store the character

void setup() 
{
	mySerial.begin(2400);
	pinMode(activePin, OUTPUT);
	digitalWrite(activePin, LOW);
}

void(* resetFunc) (void) = 0;

void loop()
{
	if (Comp("BANGBANG")==0) 
	{
		digitalWrite(activePin, HIGH);	//turn on relay and led
		delay(3000);	//buffer
		resetFunc();  //call reset
	}
	else
	{
		digitalWrite(activePin, LOW);
	}
}

char Comp(char* This) {
	while (mySerial.available() > 0) // Don't read unless
	// there you know there is data
	{
		if(index < 19) // One less than the size of the array
		{
			inChar = mySerial.read(); // Read a character
			inData[index] = inChar; // Store it
			index++; // Increment where to write next
			inData[index] = '\0'; // Null terminate the string
		}
	}

	if (strcmp(inData,This)  == 0) {
		for (int i=0;i<19;i++) {
			inData[i]=0;
		}
		index=0;
		return(0);
	}
	else {
		return(1);
	}
}

The code is really sloppy, but what it basically does is when the receiver receives the string BANGBANG from the transmitter, it will turn on a pin. The whole point of receiving a string is to prevent noise.

If I were to use a single byte character as the condition, that character can appear from the noise and turn that pin HIGH. I have tried that in my previous code.

But here is the new problem:
The serial trigger works perfectly when wired, but when I connect the pins to the RF modules, nothing happens at all! I used an oscilloscope to see what signal I was getting, and the transmitter was transmitting something, and the receiver was also receiving something; the modules seem to work. Maybe a problem with the data integrity?

Please give suggestion! Thanks.

Thanks everyone for the wonderful help!

I figured it all out. I just want to post this for reference.
I ended up using VirtualWire and using an ATTiny85 instead of the 45. That way the library can work.
On the ATTiny85, you can’t use functions like delay(); or millis();, or anything that involves timers, because the timer is already used by VirtualWire.
You must #include <util/delay.h>

Here is the finished product.
www.instructables.com/id/Badass-Zippo-Remote/