aa

Dependencies:   mbed nRF24L01P

Files at this revision

API Documentation at this revision

Comitter:
anmolhardik
Date:
Thu Feb 09 13:49:50 2017 +0000
Commit message:
aa

Changed in this revision

main.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
diff -r 000000000000 -r 2feca3c9c66d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 09 13:49:50 2017 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+#include "nRF24L01P.h"
+AnalogIn pot(PTB0);
+AnalogIn ldr(PTB1);
+Serial pc(USBTX, USBRX); // tx, rx
+
+nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTD0, PTD5, PTD4);    // mosi, miso, sck, csn, ce, irq
+DigitalOut RedLED(PTA5);
+
+int main()
+{
+    char count[2];
+    char TxDataCnt;
+    char temp;
+    float value1=0;
+    float value2=0;
+
+    my_nrf24l01p.powerUp();
+    my_nrf24l01p.setRfFrequency(2408);
+
+    // 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   : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() );
+    pc.printf( "nRF24L01+ RX Address   : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() );
+
+    pc.printf( "Simple Transmitter (0 - 9 Counter) \r\n");
+
+    TxDataCnt = 2;
+    my_nrf24l01p.setTransferSize(TxDataCnt);
+
+    my_nrf24l01p.enable();
+
+    
+    while (1) {
+    
+        value1=pot.read()*3.3;
+        value2=ldr.read()*3.3;
+        count[0] = value1*100;
+        count[1] = value2*100;
+
+        pc.printf("pot=%0.2f\r\n",value1);
+        pc.printf("ldr=%0.2f\r\n",value2);
+
+        // Send the Transmit buffer via the nRF24L01+
+        temp = my_nrf24l01p.write( NRF24L01P_PIPE_P0,count, TxDataCnt );
+
+        pc.printf( "Sending %d - %d %d\r\n",temp,count[0],count[1]);
+
+        // Toggle LED1 (to help debug Host -> nRF24L01+ communication)
+        RedLED = !RedLED;
+        
+        wait(1);
+    }
+}
diff -r 000000000000 -r 2feca3c9c66d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Feb 09 13:49:50 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/176b8275d35d
\ No newline at end of file
diff -r 000000000000 -r 2feca3c9c66d nRF24L01P.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF24L01P.lib	Thu Feb 09 13:49:50 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Owen/code/nRF24L01P/#8ae48233b4e4