Monish Kapadia / Mbed 2 deprecated LAB24_Node1

Dependencies:   mbed nRF24L01P

Files at this revision

API Documentation at this revision

Comitter:
monish
Date:
Wed Jul 06 06:27:30 2016 +0000
Child:
1:c9a26d3b593b
Commit message:
Node1;

Changed in this revision

Node1.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
nRF24L01P.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Node1.cpp	Wed Jul 06 06:27:30 2016 +0000
@@ -0,0 +1,64 @@
+/****PIPE1 Transmitter****/
+
+#include "mbed.h"
+#include "nRF24L01P.h"
+ 
+Serial pc(USBTX, USBRX); // tx, rx
+ 
+nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTD0, PTD5, PTD4);    // mosi, miso, sck, csn, ce, irq
+DigitalOut RedLED(LED1);
+AnalogIn ldr(A1);
+ 
+int main()
+{
+    char count[1];
+    char TxDataCnt;
+    char temp;
+    
+    //set tx and rx address for pipe1: 5bytes long; different for every pipe
+    long long TxAddress_PIPE1 = 0xE2E2E2E2E2;
+    long long RxAddress_PIPE1 = 0xE2E2E2E2E2;
+ 
+    my_nrf24l01p.powerUp();
+    my_nrf24l01p.setRfFrequency(2475);
+    
+    //set tx address
+    my_nrf24l01p.setTxAddress(TxAddress_PIPE1);
+    
+    //set rxaddress with default width for specified pipe
+    my_nrf24l01p.setRxAddress(RxAddress_PIPE1, DEFAULT_NRF24L01P_ADDRESS_WIDTH, NRF24L01P_PIPE_P1);
+    
+    // Display the (default) setup of the nRF24L01+ chip
+    pc.printf( "nRF24L01+ Frequency    : %d MHz\r\n",  my_nrf24l01p.getRfFrequency() );
+    pc.printf( "nRF24L01+ Output power : %d dBm\r\n",  my_nrf24l01p.getRfOutputPower() );
+    pc.printf( "nRF24L01+ Data Rate    : %d kbps\r\n", my_nrf24l01p.getAirDataRate() );
+    pc.printf( "nRF24L01+ TX Address - PIPE1   : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() );
+    
+    pc.printf( "Wirelesss sensor network \r\n");
+        
+    TxDataCnt = 1;
+    
+    //set transfer size for each pipe
+    my_nrf24l01p.setTransferSize(TxDataCnt, NRF24L01P_PIPE_P1);
+    my_nrf24l01p.enable();
+    
+    char ldr_val;
+    
+    while (1) {
+        
+        //adjusting data to 0-255 with char data type
+        ldr_val = 255*(ldr.read());
+        
+        count[0] = ldr_val;
+        
+        //transmit on specified pipe
+        temp = my_nrf24l01p.write( NRF24L01P_PIPE_P1,count, TxDataCnt );
+ 
+        pc.printf( "Sending %d bytes from PIPE1; LDR=%d\r\n",temp,count[0]);
+ 
+        // Toggle LED1 (to help debug Host -> nRF24L01+ communication)
+        RedLED = !RedLED;
+          
+        wait(10);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jul 06 06:27:30 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF24L01P.lib	Wed Jul 06 06:27:30 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Owen/code/nRF24L01P/#8ae48233b4e4