FN

Dependencies:   mbed RF24Network RF24

Files at this revision

API Documentation at this revision

Comitter:
belkaous
Date:
Mon Apr 08 12:52:19 2019 +0000
Parent:
6:4840dd0ef133
Commit message:
FN

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 4840dd0ef133 -r 77a1606d3b7e main.cpp
--- a/main.cpp	Mon Apr 01 11:52:07 2019 +0000
+++ b/main.cpp	Mon Apr 08 12:52:19 2019 +0000
@@ -8,13 +8,19 @@
 PwmOut mypwm(D5);
  
 RF24 radio(SPI_MOSI, SPI_MISO, SPI_SCK, D9, SPI_CS );
- 
+
+DigitalIn A(D8);
+DigitalIn B(D7);
+DigitalIn C(D6);
+
+
 // Network uses that radio
 RF24Network network(radio);
  
+ 
 // Address of our node
-const uint16_t this_node = 03;
- 
+uint16_t this_node;
+
 // Address of the other node
 const uint16_t other_node = 00;
  
@@ -45,10 +51,14 @@
     mypwm.pulsewidth_us(20);
     mypwm.write(0.0);
     
+if((!A.read()) && (!B.read()) && (C.read()) ) this_node = 01;
+else if(!(A.read()) && (B.read()) && !(C.read()) ) this_node = 02;
+else this_node = 03;
+
     pc.baud(115200);
     wait_ms(500);
  
-    pc.printf("mBed RF24Network node\n");
+    pc.printf("mBed RF24Network node\r\n");
     radio.begin();
     network.begin(/*channel*/ 90, /*node address*/ this_node);
     wait_ms(1000);