Saturday, October 22, 2011

Servo Turns When RF Trigger is Tripped

This example shows how you could integrate an actuator with the original sender/receiver system.

To achieve this you will have to wire up a servo to ground, power and a control pin. Such as;
This fritzing diagram is from an old project of mine where we were controlling a servo from a switch via a web feed.

To integrate the Xbee with this system, using the proximity RF trigger instead of switch and web feed seemed an appropriate application for the Xbee trigger system. This could be useful in a number of situations such as an automatic garage door, which opens when you drive your car in range.

You will need to wire any extra components you are trying to integrate, into the breakout pins on the Xbee shield, in the same relative position as if you were plugging it straight into the pins on your Arduino.

To trigger the state of the servo with Xbee, the sender should remain as usual;

void setup(){

void loop(){

The receiver/actuator sketch will look something like this;

The possibilities for integration with your own systems are vast so I thought I'd go one step further, showing you how to add a sensor to the pictured sketch above. This will give the example system a new layer of complexity, adding new variables to test against and use in system function;


Servo myservo;

int pos = 0;
int potpin = 0;
int val;

void setup(){

void loop(){
val = analogRead(potpin);
//val = map(val, 0, 1023, 0, 179);

if(Serial.available() > 0 && val > 500){

for(pos = 0; pos < 180; pos += 1) { myservo.write(pos); delay(15); } for(pos = 180; pos>=1; pos-=1)
else {

No comments:

Post a Comment