lanoo Posted May 30, 2011 Report Share Posted May 30, 2011 Hello Guys:This is a demo of nRF24L01 module, which show how to control it by using Arduino. This is the part of the code.void setup() { SPI_DIR = ( CE + SCK + CSN + MOSI); SPI_DIR &=~ ( IRQ + MISO); // attachInterrupt(1, _ISR, LOW);// interrupt enable Serial.begin(9600); init_io(); // Initialize IO port unsigned char status=SPI_Read(STATUS); Serial.print("status = "); Serial.println(status,HEX); // read the mode’s status register, the default value should be ‘E’ Serial.println("*******************TX_Mode Start****************************"); TX_Mode(); // set TX mode } void loop() { int k = 0; for(;;) { for(int i=0; i<32; i++) tx_buf[i] = k++; unsigned char status = SPI_Read(STATUS); // read register STATUS's value if(status&TX_DS) // if receive data ready (TX_DS) interrupt { SPI_RW_Reg(FLUSH_TX,0); SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH); // write playload to TX_FIFO } if(status&MAX_RT) // this is retransmit than SETUP_RETR { SPI_RW_Reg(FLUSH_TX,0); SPI_Write_Buf(WR_TX_PLOAD,tx_buf,TX_PLOAD_WIDTH); // disable standy-mode } SPI_RW_Reg(WRITE_REG+STATUS,status); // clear RX_DR or TX_DS or MAX_RT interrupt flag delay(1000); } }The whole code is here: http://www.elecfreaks.com/203.htmlThis is just one way to use the module, any other ideas? Thank you for your help first. Quote Link to comment Share on other sites More sharing options...
Terryking Posted September 26, 2011 Report Share Posted September 26, 2011 Look here: http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowToRegards, Terry King...On the Mediterranean in Italy[email protected] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.