2009
10.25

This video shows a very basic setup of two arduinos talking wireless over RF.

The two rf-boards used in this setup were discussed earlier in this post.

The left arduino has a sensorshield with a PIR-sensor and a rf-transmitter connected to it. When the PIR-sensor detects changes in IR-radition in it’s field of view, it triggers the rf-transmitter and a red led.

The right arduino just has a rf-receiver and a green led connected to it. When the right arduino receives a radio signal the green led turns on.

Code for the transmitting arduino:

int ledPin = 12;                 // pin
int pirPin = 4;                  // pin for PIR-sensor
int RFoutPin = 7;                // pin for RF transmitter
int value = 0;                   // used to store data from PIR-sensor

void setup() {
pinMode(RFoutPin, OUTPUT);       // declare RF-transmitter as output
  pinMode(ledPin, OUTPUT);       // declare led as output
pinMode(pirPin, INPUT);          // declare PIR-sensor as input
}

void loop() {
value = digitalRead(pirPin);     // read PIR-sensor
if (HIGH == value) {             // transmit HIGH signal
digitalWrite(RFoutPin, HIGH);
digitalWrite(ledPin, HIGH);
}
else {                           // transmit LOW signal
    digitalWrite(RFoutPin, LOW);
    digitalWrite(ledPin, LOW);
 }

}

Code for the receiving side:

int ledPin = 11;                  // pin for the LED
int RFinPin = 7;                  // pin for the RF receiver
int val = 0;                      // variable for reading the pin status
void setup() {
pinMode(ledPin, OUTPUT);          // declare LED as output
pinMode(RFinPin, INPUT);          // declare RF receiver as input
}
void loop(){
 val = digitalRead(RFinPin);      // read input value
 if (val == HIGH) {               // check if the input is HIGH
    digitalWrite(ledPin, HIGH);   // turn LED ON
 } else {
  digitalWrite(ledPin, LOW);      // turn LED OFF
  }
}

Ok, maybe this example was a bit too easy.

Check part 2 to learn how to connect arduino to a network and send/receive data to/from a webpage using the ethernet shield discussed here.

Back to homepage

  • Share/Bookmark

4 comments so far

Add Your Comment
  1. I’m interested in knowing about arduino’s and other sensor equipment.
    One is a microwave sensor.
    These are used in vehicle security alarms, and the sensor alone can be bought on ebay for pretty cheap.
    The explanation on ebay is that you can attach it to many security alarms.
    It’s basically a Proximity Detector, working in the microwave range.

    Can this unit be used exactly the same os the PIR sensor?

    Any help of this would be greatly appreciated!

  2. If all the proximity detector does is give a high/low signal when something is detected it should work the same as for the PIR sensor ( atleast if working voltages and currents for the proximity detector are in the working range of the arduino ).

  3. hey dude ..nice video …

    how can i contact u ..need ur advice buddy…

  4. Hey,

    you can always use the form on the contact page to send me a mail.

Please leave these two fields as-is:
Prove you are human by reading this resistor:
0Ω+/- 5%

0
0
1
2
3
4
5
6
7
8
9

0
0
1
2
3
4
5
6
7
8
9

0
0
1
2
3
4
5
6
7
8
9

5
5
10
20

Match the sliders on the left to each color band on the resistor.

Click Here for a new resistor image.

If you'd like to learn more, read about resistor color codes here.