dnanasim

Untitled

Mar 16th, 2015
278
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //TRANSMITTER ---- UNO
  3.  
  4. /* pin connections
  5. ===============
  6.  
  7. 2 -> CD
  8. 3 -> DR
  9. 7 -> CE
  10. 8 -> PWR
  11. 9 -> TXE
  12. 10 -> CSN
  13. 11 -> SI
  14. 12 -> SO
  15. 13 -> SCK
  16.  
  17. */
  18.  
  19. #include <nRF905.h>
  20. #include <SPI.h>
  21.  
  22. #define TXADDR {0xFE, 0x4C, 0xA6, 0xE5}
  23. #define RXADDR {0x58, 0x6F, 0x2E, 0x10}
  24. //#define SW_PIN A0
  25.  
  26. void setup()
  27. {
  28. nRF905_init();
  29. //nRF905_setFrequency(nRF905_band_t band, NRF905_BAND);
  30. //
  31. //nRF905_setCRC(nRF_CRC_16);
  32. nRF905_setPayloadSize(NRF905_MAX_PAYLOAD);
  33. byte addr[] = RXADDR;
  34. nRF905_setRXAddress(addr);
  35. nRF905_setTransmitPower(NRF905_PWR_n10);
  36. nRF905_setLowRxPower(NRF905_LOW_RX_ENABLE);
  37. nRF905_receive();
  38.  
  39. pinMode(A0,INPUT);
  40. pinMode(6,OUTPUT);
  41. }
  42.  
  43. void loop()
  44. {
  45. byte buffer[1];
  46. while(!nRF905_getData(buffer,sizeof(buffer)))
  47. {
  48. digitalWrite(6,HIGH);
  49. }
  50.  
  51. buffer[1] = digitalRead(A0);
  52.  
  53. byte addr[] = TXADDR;
  54. nRF905_setTXAddress(addr);
  55.  
  56. nRF905_setData(buffer,sizeof(buffer));
  57. while(!nRF905_send())
  58. {
  59. digitalWrite(6,LOW);
  60. }
  61.  
  62. nRF905_receive();
  63. }
RAW Paste Data