ben johansen
RF transmitter receiver pinout
I got this cheap wireless RF transmitter / receiver pair (from sparkfun) to work very well using VirtualWire.h library (pdf). I think I got it to transmitted from one arduino to another up to about 300 feet (according to what it looked like on Google Maps).
It is very simple to wire up. The switches attached to digital pin 9 and 10 have a 220ohm resister between the digital pin and ground – then one wire from the switch goes to the digital pin and the other goes to 5V. The receiver and transmitter are wired as follows. Someone said to connect the data pins together, but it works great as shown below (I think Tom Igoe explains that the data pins are different, the one I leave untouched can be used in different applications).
Here is the code I adapted for the transmitter (from the VirtualWire.h library examples).
Here is the code I adapted for the receiver (from the VirtualWire.h library examples).
It is easy to get the arduinos to react differently depending on what you put in the end of the receiver code. For example, one receiver arduino could have the following code, which would light an LED on pin10 if switch1 were depressed:
////// if statements comparing incoming message //////
if (strcmp(inString, "N") == 0){
digitalWrite(10, true);
}
if (strcmp(inString, "Y") == 0){
digitalWrite(10, false);
}
digitalWrite(13, false); // turn off LED to show done
}
}
=================================================================
=================================================================
The other receiver arduino could have the following code, which would light an LED on pin10 if switch2 were depressed:
////// if statements comparing incoming message //////
if (strcmp(inString, "O") == 0){
digitalWrite(10, true);
}
if (strcmp(inString, "Z") == 0){
digitalWrite(10, false);
}
digitalWrite(13, false); // turn off LED to show done
}
}
RF transmitter receiver pinout
I got this cheap wireless RF transmitter / receiver pair (from sparkfun) to work very well using VirtualWire.h library (pdf). I think I got it to transmitted from one arduino to another up to about 300 feet (according to what it looked like on Google Maps).
It is very simple to wire up. The switches attached to digital pin 9 and 10 have a 220ohm resister between the digital pin and ground – then one wire from the switch goes to the digital pin and the other goes to 5V. The receiver and transmitter are wired as follows. Someone said to connect the data pins together, but it works great as shown below (I think Tom Igoe explains that the data pins are different, the one I leave untouched can be used in different applications).
Here is the code I adapted for the transmitter (from the VirtualWire.h library examples).
Here is the code I adapted for the receiver (from the VirtualWire.h library examples).
It is easy to get the arduinos to react differently depending on what you put in the end of the receiver code. For example, one receiver arduino could have the following code, which would light an LED on pin10 if switch1 were depressed:
////// if statements comparing incoming message //////
if (strcmp(inString, "N") == 0){
digitalWrite(10, true);
}
if (strcmp(inString, "Y") == 0){
digitalWrite(10, false);
}
digitalWrite(13, false); // turn off LED to show done
}
}
=================================================================
=================================================================
The other receiver arduino could have the following code, which would light an LED on pin10 if switch2 were depressed:
////// if statements comparing incoming message //////
if (strcmp(inString, "O") == 0){
digitalWrite(10, true);
}
if (strcmp(inString, "Z") == 0){
digitalWrite(10, false);
}
digitalWrite(13, false); // turn off LED to show done
}
}