i am trying to write two scripts, A Tx and a Rx, These are controlled using serial data sent from vixen lights software. RX script
#include <FastLED.h>
#include <RF24.h>
#define DATA_PIN 6
#define NUM_LEDS 10
CRGB leds[NUM_LEDS];
RF24 radio(9, 10);
byte addresses[][6] = {"Vixen1"};
void setup() {
Serial.begin(115200);
FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
radio.begin();
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_2MBPS);
radio.setChannel(124);
radio.openReadingPipe(0, addresses[0]);
radio.startListening();
}
void loop() {
if (radio.available()) {
// Calculate the number of pixels based on the number of LEDs we are expecting
unsigned int num_leds = 10; // Or however many LEDs you have
byte incomingByte[num_leds * 3];
radio.read(&incomingByte, sizeof(byte) * num_leds * 3);
for (int i = 0; i < num_leds; i++) {
int channel = i * 3;
byte r = incomingByte[channel];
byte g = incomingByte[channel + 1];
byte b = incomingByte[channel + 2];
leds[i] = CRGB(r, g, b);
}
// Tell the FastLED Library it is time to update the strip of pixels
FastLED.show();
}
// Other tasks to perform during each iteration of the loop can be added here.
}
TX script
#include <SPI.h>
#include <RF24.h>
// How many channels Vixen will control
#define MAX_CHANNELS 300
// Stores the value of each channel
byte outgoingByte[MAX_CHANNELS];
// Uses SPI bus + two digital pins for chip enable (CE) and chip select (CSN)
RF24 radio(9, 10);
// An address used by the transmitter and receiver
// Changing this address would allow multiple Vixen server instances to control
// different sets of clients while still operating on the nRF channel.
byte addresses[][6] = {"Vixen1"};
void setup() {
Serial.begin(115200);
radio.begin();
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_2MBPS);
radio.setChannel(124);
radio.openWritingPipe(addresses[0]);
}
void loop() {
// Keeps track of place in byte array and how many channels are left to be read
unsigned int remaining;
unsigned int channel;
for (;;) {
// Header character is used to keep the Arduino in sync with first channel as Vixen sequentially
// writes out each byte for every channel.
while (!Serial.available());
if (Serial.read() != '>') {
continue;
}
remaining = MAX_CHANNELS;
channel = 0;
do {
while (!Serial.available());
outgoingByte[channel++] = Serial.read();
}
while (--remaining);
// Write out the byte array of channel values to the nRF
radio.write(&outgoingByte, sizeof(byte) * MAX_CHANNELS);
}
}
I have been using these scripts, I'm thinking now, Because the Nrf can only transmit 32 bytes.
I have tried searching the internet but no solution so far. I am only able to control the First 10 Pixels accurately on my strip I am using a Header in my Vixen lights software that is > I think it will be a scrap it and new approach type job I'm stumped. Any tips, Advice much appreciated. I think I am going to have to take the approach whereby I break it into packets and reassemble the Data received on the receiver side and then feed the LEDs, but I'm stuck :/ Thanks.