Advertisement
Electgpl

ARDUINO - Cliente NRF24L01

Jul 7th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. // NRF24l01 - Codigo Cliente.
  2. #include <SPI.h>
  3. #include <Mirf.h>
  4. #include <nRF24L01.h>
  5. #include <MirfHardwareSpiDriver.h>
  6. #include <Wire.h>
  7. //Estructura de datos a recibir
  8. struct DATOS{
  9.     unsigned long time;
  10. }datos;
  11. //Funcion de configuracion
  12. void setup(){
  13.     Serial.begin(9600);
  14.     Mirf.spi    = &MirfHardwareSpi;
  15.     Mirf.cePin  = 8;
  16.     Mirf.csnPin = 10;
  17.     Mirf.init();
  18.     Mirf.setRADDR((byte *)"client");
  19.     Mirf.payload = sizeof(datos);
  20.     Mirf.channel = 10;
  21.     Mirf.config();
  22. }
  23. //Funcion de iteracion infinita
  24. void loop(){
  25.     if(!Mirf.isSending()&Mirf.dataReady()){
  26.         Mirf.getData((byte *)&datos);
  27.         Serial.println(datos.time);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement