Hi! I'm marta and I want to connect bluetooth module HC-05 and NRF24L01 at the same time. HC-05 code works but when I write the NRF's code in the HC's code it doesn´t work, can you help me?
the code is:
#include <SoftwareSerial.h> //Librería que permite establecer comunicación serie en otros pins
#include <nRF24L01.h>
#include <printf.h>
#include <SPI.h>
#include <RF24.h>
#include <RF24_config.h>
//Aquí conectamos los pins RXD,TDX del módulo Bluetooth.
SoftwareSerial BT(10,11); //10 RX, 11 TX.
#define CE_PIN 8
#define CSN_PIN 7
RF24 radio(CE_PIN, CSN_PIN);
// Se declara el canal (64 bits en hexadecimal) para transmisión RF
const uint64_t canal = 0xE8E8F0F0E1LL;
#define CONTROL 13 //tenemos 13 controles luz, seguridad, persianas, humo, puerta y los modos automático/manual, abrir/cerrar, activar/desactivar, subir/bajar/parar
char val;
unsigned int estado[CONTROL]; //ponemos control 4 porque va del 0 al 4 y eso hace un total de 5
int recibido;
int A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S;
void setup()
{
BT.begin(9600);
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(canal);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop()
{
if(BT.available()) // Si llega un dato por el puerto BT se envía al monitor serial
{
Serial.write(BT.read());
Serial.write("Hola mundi");
}
if(Serial.available()) // Si llega un dato por el monitor serial se envía al puerto BT
{
BT.write(Serial.read());//luego descomentar
val = Serial.read();
}
if( val == '1' )
{
digitalWrite(7, HIGH);
}
//hacia bajo es lo nuevo Creo que es esto lo que funciona.
if( Serial.available() ) {
val = Serial.read();
}
}