Blame view

code arduino/com_Xbee/code_receveur/receveurXbee.ino 546 Bytes
c4726d68   aknockae   ajout du code ard...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  /* Output-side (LED) Arduino code */
  #include "SoftwareSerial.h"
  // RX: Arduino pin 2, XBee pin DOUT.  TX:  Arduino pin 3, XBee pin DIN
  SoftwareSerial XBee(0, 1);
  int LED = 13;
  
  void setup()
  {
    // Baud rate MUST match XBee settings (as set in XCTU)
    XBee.begin(9600);
    pinMode(LED, OUTPUT);
  }
  
  void loop()
  {
    if (XBee.available())  
    { 
      char c = XBee.read();
      if (c == 'H')
      {
        digitalWrite(LED, HIGH);
        delay(50);
      }
      else
      {
        digitalWrite(LED, LOW);
      }
    }
    else
    {
      digitalWrite(LED, LOW);
    }
  }