Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MMA8451Q TSI USBDevice mbed nRF24L01P
Fork of kl25Z_nRF_RX by
Receiver.cpp
00001 #include "mbed.h" 00002 #include "nRF24L01P.h" 00003 #include "MMA8451Q.h" 00004 #include "TSISensor.h" 00005 #include "USBMouse.h" 00006 #define MMA8451_addr (0X1d<<1) 00007 USBMouse mouse; 00008 MMA8451Q acc(PTE25,PTE24,MMA8451_addr); 00009 TSISensor tsi; 00010 Serial pc(USBTX, USBRX); 00011 nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTD0, PTD5, PTD4); 00012 00013 int main() 00014 { 00015 char count[4]; 00016 char RxDataCnt; 00017 float x,y; 00018 char temp; 00019 my_nrf24l01p.powerUp(); 00020 my_nrf24l01p.setRfFrequency(2400); 00021 00022 RxDataCnt = 4; 00023 my_nrf24l01p.setTransferSize( RxDataCnt ); 00024 00025 my_nrf24l01p.setReceiveMode(); 00026 my_nrf24l01p.enable(); 00027 00028 while (1) 00029 { 00030 00031 if ( my_nrf24l01p.readable() ) 00032 { 00033 temp = my_nrf24l01p.read( NRF24L01P_PIPE_P0, count, RxDataCnt ); 00034 // pc.printf( "Cnt %d = %d %d %d %d\r\n",temp,count[0],count[1],count[2],count[3]); 00035 y=count[0]; 00036 x=count[1]; 00037 y=(y/50.0f)-(float)2; 00038 x=(x/50.0f)-(float)2; 00039 mouse.move(-1.0f*y*20.0f,x*20.0f); 00040 if(count[2]==1) 00041 { 00042 mouse.press(MOUSE_LEFT); 00043 } 00044 else if(count[3]==1) 00045 { 00046 mouse.press(MOUSE_RIGHT); 00047 } 00048 else 00049 { 00050 mouse.release(MOUSE_LEFT); 00051 mouse.release(MOUSE_RIGHT); 00052 } 00053 00054 wait_ms(50); 00055 } 00056 } 00057 }
Generated on Tue Jul 19 2022 22:42:51 by
1.7.2
