RF communication between Arduinos
Overview
Many people have sent communications between an arduino and another computer using a serial connection, perhaps in a course like CSE 132. Most people, though, do not have experience communicating wireless between arduinos using Radio Frequency technology. Let's dig in.
Materials
You will need:
-2 arduinos (most types will work, uno and mega definitely will)
-virtualWire library download (http://www.resistorpark.com/arduino-virtualwire-library-download/)
-RF Link Receiver (https://www.sparkfun.com/products/10532)
-RF Link Transmitter (https://www.sparkfun.com/products/10534)
-A breadboard
-Around 15 wires
-1 7V-12V power supply for arduino
-1 Serial connection for arduino
Setting up the transmitter
-connect the top pin on the transmitter to GND on arduino ('top' pin is the one farthest away from the 'ant' pin)
-connect second from top pin on transmitter to digital pin 12 on arduino
-connect third pin from top on transmitter to 5V power supply on arduino
Upload the following code to the arduino connected to the transmitter:
- include <VirtualWire.h>
char *controller;
void setup() {
pinMode(13,OUTPUT);
vw_set_ptt_inverted(true);
vw_set_tx_pin(12);
vw_setup(2400);// speed of data transfer Kbps
}
void loop(){
controller="1" ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13,1);
delay(2000);
controller="0" ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13,0);
delay(2000);
}