Pages: [1]   Go Down
Author Topic: Sending signals to the xBee Transmiter  (Read 814 times)
0 Members and 1 Guest are viewing this topic.
Honduras
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
The title probably sounds strange, but I have two xBees. I use one for transmitting and another for receving. I am turning a led with a button
I want to create a small web application for turning on the led. So my idea is send data to the the transmitter and the transmitter will send data to the receiver. The problem is I am not sure if this is the correct way of doing it. Any idea?

The source code of both is the following

Transmitter Code
 
Code:
int BUTTON = 5;
  void setup()
  {
    pinMode(BUTTON, INPUT);
    Serial.begin(9600);
  }
 
  void loop()
  {
  // send a capital D over the serial port if the button is pressed
    if (digitalRead(BUTTON) == HIGH)
    {
      Serial.print('D');
      delay(10); // prevents overwhelming the serial port
    }
  }

Receiver Code

Code:
int BELL = 13;
  void setup()
  {
    pinMode(BELL, OUTPUT);
    Serial.begin(9600);
  }
 
  void loop()
  {
    // look for a capital D over the serial port and ring the bell if found
    if (Serial.available() > 0)
    {
      if (Serial.read() == 'D')
      {
        //ring the bell briefly
        digitalWrite(BELL, HIGH);
        delay(10);
        digitalWrite(BELL, LOW);
      }
    }
  }
Logged

New River, Arizona
Offline Offline
God Member
*****
Karma: 19
Posts: 935
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Which series of XBees are you using 1 or 2?  To do what you want to do using strictly transparent mode, they have to be set up as coordinator and router (or end device).  There's a number of things you need to do to get this to work.  What have you set up so far?

But basically, the code you have should get you started if the XBees are already set up and ready to go.  One of the folk on this forum has a blog post for getting started the first time with a series 2 XBee it's here <link> Take a look and then give it a try.
Logged

Trying to keep my house under control http://www.desert-home.com/

Honduras
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have then working in transparent mode. I have my coordinator and router. They work perfect.
But right now I want to create a small web app. When I click the bottom on my web application a signal has to been send to the transmitter and the transmitter is going to send the signal to the receiver. (I assume it works that way). But not sure any link for that?
Logged

New River, Arizona
Offline Offline
God Member
*****
Karma: 19
Posts: 935
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Then the code you have is a reasonable place to start, hook it up and give it a try.  However, change the delays in the code from 10 to a 1000 or more.  The unit for delay is millisecond and 10 isn't enough for the transmitter and 10 on the receiver won't be enough to sound a bell or alarm or whatever.  Use a second on the transmitter and around 500 on the bell to start off with.
Logged

Trying to keep my house under control http://www.desert-home.com/

Honduras
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code is working perfectly.
The problem is I need a way to send signal to the transmitter. I want to have both way pressing the physical bottom or clicking in a website a bottom to send a signal.
Logged

New River, Arizona
Offline Offline
God Member
*****
Karma: 19
Posts: 935
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Check in the forum on networking.  There are a lot of internet related posts there that you can get information from.
Logged

Trying to keep my house under control http://www.desert-home.com/

Honduras
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What I have just read I have to change the mode to the API Mode to make this work the way I want.
Logged

Pages: [1]   Go Up
Jump to: