So, i've finished paint the controller, and did a 2k clear coat on it that turned out nice. with it being painted i was able to do the wiring, 8 hours later it was done. and then too many hours to count I've build the GIU and have started to make it wireless.
The main control is the arduino mega. which handles the SPI control with the RA8875 TFT 7" screen, i did this because there's an issue with the chip that requires you to use an extra tri state chip in order to add other items to the SPI when using the TFT display. BUt I've seen posts about people using the TFT and NRF24 even with the tri state chip.
To combat this issue I added a pro mini 3.3v to communicate with the NRF24. I'm using the easy transfer library to make it easier to send the variables that I need to for the lights. as I'm using a structure array to send the values to the wireless lights. The pro mini and NRF24 +pa+lna are powered with a 3.3v regulator that can meet their energy requirements.
The issue I'm having is that I can make the pro mini send the data to the lights but the moment I add Serial.Begin(9600) (I've tried different baud rates as well). the code stops working. Although I used the serial as a debugger as well. the code is running and printing out on serial but there is no outgoing radio communication happening. The serial port has DIP switches wire between the pro mini and serial1 on the mega to allow for me to program the pro mini without any issues.
I've been able to recreate this problem on the pro mini + NRF24 pa ina, Pro mini + NRF24, and Nano + NRF24
all combinations have the same effect. I've also tried switching to the I2C easy transfer library with the same issue.
Any thoughts on how I could make this work are greatly appreciated.
Code of the lights (receivers) // this works fine no issues
#include "nRF24L01.h" // NRF24L01 library created by TMRh20 https://github.com/TMRh20/RF24
#include "RF24.h"
#include "SPI.h"
#include <Adafruit_NeoPixel.h>
#define NUM_LEDS 1 // Number of leds on stick
#define PIN 3 // Digital In (DI) of RGB Stick connected to pin 8 of the UNO
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRBW + NEO_KHZ800);
RF24 radio(9,10); // NRF24L01 used SPI pins + Pin 9 and 10 on the UNO
const byte pipe = "000001"; // Needs to be the same for communicating between 2 NRF24L01
struct Data_Package {
byte MODE_num;
byte LED_num;
uint32_t color;
uint8_t music1;
uint8_t music2;
uint8_t music3;
uint8_t music4;
uint8_t music5;
};
Data_Package data;
int n;
uint32_t color_recieved = 0;
/////////////////////////////////////////////////////
//
// these variable need to be changed for each module
//
/////////////////////////////////////////////////////
#define module_num 5 // (between 1 - 50) // sets color channel
//#define music_num 4 // (between 1 - 5) // sets music channel
// set the music color
uint32_t music_color = strip.Color(0,0,data.music5,0);
void setup(void){
strip.begin();
strip.show(); // Initialize all pixels to 'off'
radio.begin(); // Start the NRF24L01
radio.openReadingPipe(1,pipe); // Get NRF24L01 ready to receive
radio.setAutoAck(1,false);
radio.startListening(); // Listen to see if information received
data.LED_num = 0;
data.color = 0;
strip.setPixelColor(0,0,0,0,50);
strip.show();
delay(500);
// strip.setPixelColor(0,0,0,0,50);
// strip.show();
}
void loop(void){
while (radio.available()){
radio.read(&data, sizeof(Data_Package)); // Read information from the NRF24L01
if (data.MODE_num == 0){
if (data.LED_num == module_num){
color_recieved = data.color;
}}
if (data.MODE_num == 1){ // activate music mode
// uint32_t music_color = strip.Color(0,0,0,0);
color_recieved = music_color;
} // end of music mode
}
strip.setPixelColor(0,color_recieved);
strip.show();
} // end loop
//Pro mini sending Code
(currently set to send the color code itself so no communication from mega at this point)
leaving serial or I2C commented means the lights go green, red, blue no issues.
adding serial and the number println, it will show the numbers on the serial monitor but no action from the lights.
#include "nRF24L01.h" //NRF24L01 library created by TMRh20 https://github.com/TMRh20/RF24
#include "RF24.h"
#include "SPI.h"
#include <EasyTransferI2C.h>
#include <Adafruit_NeoPixel.h>
EasyTransferI2C ET;
#define I2C_SLAVE_ADDRESS 9
#define num_modules 5
Adafruit_NeoPixel strip = Adafruit_NeoPixel(num_modules, 5, NEO_GRBW + NEO_KHZ800);
int i = 0;
int v = 0;
RF24 radio(9,10); // NRF24L01 used SPI pins + Pin 9 and 10 on the NANO
const byte pipe = "000001"; // Needs to be the same for communicating between 2 NRF24L01
/////// data to be changed for sending and receiving
unsigned long patternInterval1 = 50 ; // time between steps in the pattern
unsigned long patternInterval2 = 75 ; // time between steps in the pattern
unsigned long lastUpdate = 0 ; // for millis() when last update occoured
struct Data_Package {
byte MODE_num;
byte LED_num;
uint32_t color;
uint8_t music1;
uint8_t music2;
uint8_t music3;
uint8_t music4;
uint8_t music5;
};
Data_Package data;
struct Data_income {
uint32_t color1; // color 1
uint32_t dualcolor1; // dual color 1
uint32_t dualcolor2; // dual color 2
uint8_t patternspeed; // animation speed
uint8_t patternbrightness; // animation brightness
uint8_t music1; // music values
uint8_t music2; // music values
uint8_t music3; // music values
uint8_t music4; // music values
uint8_t music5; // music values
uint8_t auction; // what table number sellected for auction
uint8_t animation; // what animation mode is selected
uint8_t button; // what mode is the controller in
};
Data_income income;
void setup() {
// put your setup code here, to run once:
//Serial.begin(9600);
// ET.begin(details(income), &Serial);
//Wire.begin(I2C_SLAVE_ADDRESS);
//ET.begin(details(income), &Wire);
//Wire.onReceive(receive);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
radio.begin(); // Start the NRF24L01
radio.openWritingPipe(pipe); // Get NRF24L01 ready to transmit
radio.setAutoAck(false);
data.MODE_num = 0;
data.LED_num = 0;
data.color = 0;
}
void loop() {
// put your main code here, to run repeatedly:
//ET.receiveData(); // incoming data
colorSET(strip.Color(0,255,0,0));
delay(200);
//Serial.println("1");
colorSET(strip.Color(255,0,0,0));
delay(200);
//Serial.println("2");
colorSET(strip.Color(0,0,255,0));
delay(200);
//Serial.println("3");
}
void receive(int numBytes) {}
void updating(){
radio.write(&data, sizeof(Data_Package));
radio.write(&data, sizeof(Data_Package));
radio.write(&data, sizeof(Data_Package));
}
void auctionSET(uint8_t c) {
for(uint16_t i=1; i<num_modules; i++) {
if (i == c){
data.LED_num = c;
data.color = (strip.Color(0,0,0,255));
}else{
data.LED_num = i;
data.color = (strip.Color(150,0,0,0));
} updating();
}}
void colorSET(uint32_t c) {
for(uint16_t i=1; i<num_modules; i++) {
data.LED_num = i;
data.color = c;
updating();
}}
void dualSET1(uint32_t c) {
for(uint16_t v=2; v<num_modules; v=v+2) {
data.LED_num = v;
data.color = c;
updating();
}}
void dualSET2(uint32_t c) {
for(uint16_t i=1; i<num_modules; i=i+2) {
data.LED_num = i;
data.color = c;
updating();
}}
void rainbow() { // modified from Adafruit example to make it a state machine
static uint16_t j=0;
for(int i=1; i<num_modules; i++) {
uint32_t selected = (Wheel((i+j) & 255));
data.color = selected;
data.LED_num = i;
updating();
}
j++;
if(j >= 256) j=0;
lastUpdate = millis(); // time for next change to the display
}
void rainbowCycle() { // modified from Adafruit example to make it a state machine
static uint16_t j=0;
for(int i=1; i<num_modules; i++) {
uint32_t selected = (Wheel(((i * 256 / num_modules) + j) & 255));
data.color = selected;
data.LED_num = i;
updating();
}
j++;
if(j >= 256*5) j=0;
lastUpdate = millis(); // time for next change to the display
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3,0);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3,0);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0,0);
}