swathi B
/
F1NRFRx
this is full duplex led on/off involving 2 FRDM-KL25Z which act as trans recievers
Revision 2:f3f30833fd01, committed 2019-05-31
- Comitter:
- swathi31
- Date:
- Fri May 31 14:44:06 2019 +0000
- Parent:
- 1:f97915cf7a69
- Commit message:
- FULL DUPLEX LED ON/OFF USING FRDM-KL25Z
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f97915cf7a69 -r f3f30833fd01 main.cpp --- a/main.cpp Thu May 30 12:49:34 2019 +0000 +++ b/main.cpp Fri May 31 14:44:06 2019 +0000 @@ -5,16 +5,19 @@ nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTD0, PTD5, PTD4); // MOSI, MISO, SCK, CSN, CE, IRQ DigitalOut GreenLED(PTA12); - - +DigitalOut RedLED(LED2); +DigitalIn switchin(PTC9); int main() { - + char count[2]; char RxDataCnt; char temp; + + char count1[2]; + char TxDataCnt; my_nrf24l01p.powerUp(); - my_nrf24l01p.setRfFrequency(2411); + my_nrf24l01p.setRfFrequency(2410); // Display the (default) setup of the nRF24L01+ chip pc.printf( "nRF24L01+ Frequency : %d MHz\r\n", my_nrf24l01p.getRfFrequency() ); @@ -24,15 +27,25 @@ pc.printf( "nRF24L01+ RX Address : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() ); pc.printf( "Simple 2 Byte Receiver\r\n" ); - + RxDataCnt = 2; my_nrf24l01p.setTransferSize( RxDataCnt ); - + TxDataCnt = 2; + my_nrf24l01p.setTransferSize(TxDataCnt); + + my_nrf24l01p.setReceiveMode(); my_nrf24l01p.enable(); while (1) { - + if(switchin==0) { + // pc.scanf("%c",&ch); + count1[0]='1'; + pc.printf("data 1\n"); + } else { + count1[0]='0'; + } + // If we've received anything in the nRF24L01+... if ( my_nrf24l01p.readable() ) { @@ -41,11 +54,23 @@ pc.printf( "Cnt %d = %d %d\r\n",temp,count[0],count[1]); - + if(count[0]==48) + { + GreenLED=0; + } + else + { + GreenLED=1; + } // Toggle LED2 (to help debug nRF24L01+ -> Host communication) GreenLED = !GreenLED; wait_ms(10); } + temp = my_nrf24l01p.write( NRF24L01P_PIPE_P0, count1, TxDataCnt); + // Toggle LED1 (to help debug Host -> nRF24L01+ communication) + RedLED = !RedLED; + wait(1); + } }