Ok, I’m having some issues with my project. I am attempting to send data received from a transceiver and pass it to the iOS app Arduino Manager via an Adafruit nRF8001 BLE breakout module. With this, I am only able to get one communication to work at a time (either BLE or RF24, NOT BOTH). I believe this has something to do with the timing of the SPI pins, but I’m not knowledgable enough to figure it out. The code below does not contain sending the received data from the transceiver, but instead just sending a test value of 498 while all the other code is there.
Arduino Uno Code
/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include "RF24.h" //Transceiver Library
#include "IOSControllerForBluefruit.h" //BLE
/*-----( Declare Constants and Pin Numbers )-----*/
/*-----( Declare objects )-----*/
RF24 myRadio (7, 8); // "myRadio" is the identifier you will use in following methods
/*-----( Declare Variables )-----*/
byte addresses[][6] = {"1Node"}; // Create address for 1 pipe.
// Data that will be received from the transmitter
int msg[1];
int LED1 = 4;
float in, out;
int value = 498;
void setup() /****** SETUP: RUNS ONCE ******/
{
Serial.begin(9600);
//*******Transeiver********
myRadio.begin(); // Start up the physical nRF24L01 Radio
myRadio.setChannel(108); // Above most Wifi Channels
myRadio.setPALevel(RF24_PA_MIN);
myRadio.openReadingPipe(1, addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
myRadio.startListening();
//*******LED/Buzzer********
pinMode(LED1, OUTPUT);
}//--(end setup )---
void doWork();
void doSync(char *variable);
void processIncomingMessages(char *variable, char *value);
void processOutgoingMessages();
void deviceConnected();
void deviceDisconnected();
IOSControllerForBluefruit iosController(&doWork, &doSync, &processIncomingMessages, &processOutgoingMessages, &deviceConnected, &deviceDisconnected);
void doWork() {
// New Main Loop
if ( myRadio.available()) // Check for incoming data from transmitter
{
//while (myRadio.available()) // While there is data ready
if (myRadio.available()) // While there is data ready
{
myRadio.read(msg, 1);
Serial.println(msg[0]);
if (msg[0] == 110)
{
for (in = 0; in < 6.283; in = in + 0.003) {
out = sin(in) * 127.5 + 127.5;
analogWrite(LED1, out);
}
}
else if (msg[0] == 111)
{
for (in = 0; in < 6.283; in = in + 0.011) {
out = sin(in) * 127.5 + 127.5;
analogWrite(LED1, out);
}
}
else if (msg[0] == 100)
{
for (in = 0; in < 6.283; in = in + 0.0009) {
out = sin(in) * 127.5 + 127.5;
analogWrite(LED1, out);
}
}
else
{
digitalWrite(LED1, LOW);
}
delay(100);
}
}
else
{
Serial.println("No radio available");
}
}
void doSync(char *variable) {
//Serial.print("Sync "); Serial.println(variable);
}
void processIncomingMessages(char *variable, char *value) {
//Serial.print("Variable "); Serial.print(variable); Serial.print(" "); Serial.print(" Value "); Serial.println(value);
}
void processOutgoingMessages() {
//Serial.println("Outgoing");
iosController.writeMessage("Value", value); //Test value of 498
}
void deviceConnected() {
Serial.println(F("Device Connected"));
}
void deviceDisconnected() {
Serial.println(F("Device Disconnected"));
}
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
iosController.loop(); //Goes to .cpp & .h
} //End Loop
//*********( THE END )***********
IOSControllerForBluefruit.cpp (7.99 KB)
IOSControllerForBluefruit.h (3.93 KB)
RF24-master (3).zip (337 KB)