wireless educational game for use with Python3 code

Dependencies:   mbed nRF24L01P

Files at this revision

API Documentation at this revision

Comitter:
caeng
Date:
Thu Jul 09 00:32:26 2015 +0000
Commit message:
LACC quasar wireless game

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 782928220968 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 09 00:32:26 2015 +0000
@@ -0,0 +1,58 @@
+#include "mbed.h"
+#include "nRF24L01P.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9, p10);    // mosi, miso, sck, csn, ce, irq
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+int main() {
+    
+    // set up PC comm.
+    pc.baud(115200);
+    
+    // set up wireless transfer size
+    #define TRANSFER_SIZE 3
+
+    char rxData[TRANSFER_SIZE];
+    int rxDataCnt = 0;
+
+    // initialize wireless comm.
+    my_nrf24l01p.powerUp();
+    my_nrf24l01p.setTransferSize( TRANSFER_SIZE );
+    my_nrf24l01p.setReceiveMode();
+    my_nrf24l01p.enable();
+    my_nrf24l01p.setAirDataRate(2000);
+    // set wireless RX
+    my_nrf24l01p.setRxAddress(0xABCDABCDABCDABCD);
+    
+    // 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() );
+
+    while (1) {
+        led1 = 1;
+
+        // If we've received anything in the nRF24L01+...
+        if ( my_nrf24l01p.readable() ) {
+
+            // ...read the data into the receive buffer
+            rxDataCnt = my_nrf24l01p.read( NRF24L01P_PIPE_P0, rxData, sizeof( rxData ) );
+
+            // Display the receive buffer contents via the host serial link
+            for ( int i = 0; rxDataCnt > 0; rxDataCnt--, i++ ) {
+                pc.printf( "%d,", rxData[i] );
+            }
+            pc.printf("\n\r");
+
+            // Toggle LED2 (to help debug nRF24L01+ -> Host communication)
+            led2 = !led2;
+        }
+    }
+}
diff -r 000000000000 -r 782928220968 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jul 09 00:32:26 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file
diff -r 000000000000 -r 782928220968 nRF24L01P.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF24L01P.lib	Thu Jul 09 00:32:26 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Owen/code/nRF24L01P/#8ae48233b4e4