V TX RX DOS PULSOS, DOS LEDS
CODIFICADO CON LETRAS PROBADO
TX
ESQUEMA DE CONEXION
+-----+
+----[PWR]-------------------| USB |--+
| +-----+ |
| GND/RST2 [ ][ ] |
| MOSI2/SCK2 [ ][ ] A5/SCL[ ] |
| 5V/MISO2 [ ][ ] A4/SDA[ ] |
| AREF[ ] |
| GND[ ] |
| [ ]N/C SCK/13[ ] | Pin "SCK" del módulo NRF24L01
| [ ]IOREF MISO/12[ ] | Pin "MISO" del módulo NRF24L01
| [ ]RST MOSI/11[ ]~| Pin "MOSI" del módulo NRF24L01
| [ ]3V3 +---+ 10[ ]~| Pin "CSN" del módulo NRF24L01
| [ ]5v -| A |- 9[ ]~| Pin "CE" del módulo NRF24L01
| [ ]GND -| R |- 8[ ] |
| [ ]GND -| D |- |
| [ ]Vin -| U |- 7[ ] | LED(+)
| -| I |- 6[ ]~|
| [ ]A0 -| N |- 5[ ]~|
| [ ]A1 -| O |- 4[ ] |
| [ ]A2 +---+ INT1/3[ ]~|
| [ ]A3 INT0/2[ ] |
| [ ]A4/SDA RST SCK MISO TX>1[ ] |
| [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] |
| [][][] |
| UNO_R3 GND MOSI 5V ____________/
\_______________________/
//Tx
#include <SPI.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
int pulso1 = 7;
int pulso2 = 6;
int estado1 = 1;
int estado2=1;
const byte identificacion[6] = "00001"; // canal 1
void setup() {
pinMode(pulso1, INPUT);
pinMode(pulso2, INPUT);
[Link]();
[Link](identificacion);
[Link](RF24_PA_MIN);
[Link](); // Transmite
}
void loop() {
estado1= digitalRead(pulso1);
if (estado1 == LOW)
{
const char texto[] = "Hola"; // Envio el dato encriptado
[Link](&texto, sizeof(texto)); // Tx por RF
delay(1000); // Un segundo (1000 milisegundos) de espera entre envío y envío
}
estado2= digitalRead(pulso2);
if (estado2 == LOW)
{
const char texto[] = "si"; // Envio el dato encriptado
[Link](&texto, sizeof(texto)); // Tx por Rf
delay(1000); // Un segundo (1000 milisegundos) de espera entre envío y envío
}
RX
// Rx
#include <SPI.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte identificacion[6] = "00001";
int LED1 = 7;
int LED2 = 6;
char *condicion1; // para almacenar los datos letras numeros etc
char *condicion2;
void setup() {
[Link](9600);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
[Link]();
[Link](0, identificacion);
[Link](RF24_PA_MIN);
[Link](); // receptor
}
void loop() {
if ([Link]()) {
char texto[32] = "";
[Link](&texto, sizeof(texto)); // recibe los datos y guarda en variable texto
[Link](texto);
condicion1=strstr(texto,"Hola"); // almacena los datos en la variable condicion
condicion2=strstr(texto,"si");
if (condicion1 )
{
[Link]("condicion1");
digitalWrite(LED1, HIGH);
delay(500);
digitalWrite(LED1, LOW);
delay(500);
if (condicion2)
{
[Link]("condicion2");
digitalWrite(LED2, HIGH);
delay(800);
digitalWrite(LED2, LOW);
delay(800);
}