I have been trying to control an Arduino running Fast_SPI via Serial commands over

I have been trying to control an Arduino running Fast_SPI via Serial commands over Xbee unsuccessfully. From what I have researched, I understand that the Serial UART works off of interrupts to catch data. At the moment, I can confirm my serial commands are being transmitted and received thru the Xbee’s successfully. My led code is formatted in a switch case statement where the incoming serial data controls which case runs. Will the Fast_SPI library effect the ability to receive Serial data?

Depends on what LEDs you are using - if it is something with a clock as well as a data line (ws2801, lpd8806) you should be fine. If it is one of the data line only chips (ws2811, ws2812, tm1809) then things are a bit more complicated - as the timing requirements of those chips require that interrupts are disabled. In that case you basically have to have a more active back and forth of “I’m not sending led data, have anything for me?”

I have some ideas to work around this - but haven’t had a chance to test them, yet.

I’m stuck using UCS1903’s for the moment.

What library are you using to talk to the xbee’s, and how do you feel about guinea pigging an idea/some code?

To grab the serial data, code wise, I am using:

if(Serial.available() > 0){ serial = Serial.read();}

switch (serial) {
case ‘a’ : led_code(); break;
case ‘b’ : led_code2(); break;

The xbees are in AT mode, meaning they are transparent and only mirror the RX and TX ports of the Arduino out to the world.

I think I should be using Serial.event instead? Perhaps a hand shaking method? I am a bit lost…thanks for the help

@Mark_Kriegsman Here is a project where I incorporated an Adafruit Bluefruit BT Programmer. Have you purchased one yet?

I have the BT module on hand but haven’t wired it up to anything yet. It’ll be part of a project I’ll be doing after New Year’s.

@Daniel_Garcia You mentioned you had a few ideas to work around my specific issue, would you be interested in elaborating a bit? Please? I would really like to pick your brain, as you always have a clear way of summarizing the issue for a newbie. Perhaps a push in the right direction? Thanks!

It’s less of an idea to elaborate on, and more of making some code changes - namely playing with some timing around enabling/disabling interrupts - I believe I can enable interrupts and disable them in between RGB blocks of data, to allow handling of anything that fired in the middle, however, I don’t know yet whether or not that will throw the timing too much for these chipsets. I also haven’t had any chance to even think about testing this, yet, so you’d be playing with mostly untested code.

I would be glad to help in this endeavor. Sending and receiving serial data while using the library would be optimal, how can I help?

Ok - grab http://dgarcia.net/fled.zip - and install that into your libraries directory - change your include from FastSPI_LED2.h to FastLED.h – that code allows interrupts to attempt to handle in between each rgb led.

It may still be possible that this won’t be often enough for your interrupt handler to work right - as I don’t believe I can do it more frequently than what’s testing in this file - which is every 60µs (with the WS2812’s, it would be more like every 30µs).

@Daniel_Garcia I got my hands on your test code, but I am still not catching any Serial data. I think the only work around is to use the Xbees in API mode and toggle a pin LOW on the Arduino via the xbee which would then send the Arduino into a subroutine where it waits for serial data, then returns to showing the LEDS.

How much data are you sending and how many leds are you talking to?

Also - what baud rate are you setting the serial port at?

I’ve experimented with 9600 up to 115200 on just 10 leds for the moment. I am just sending a single digit to control a switch case.

How much data? The serial class, as setup by arduino only has a 32 byte buffer.

Here is my code:

#define FAST_SPI_INTERRUPTS_WRITE_PINS 1

Will this possibly be a solution? I think it’s more complex than that, but I still am trying to learn/figure out a method to communicate mode commands to an Arduino running the library, via an xbee in API. Creating a way to listen for an incoming message via the serial port is stumping me. Does anyone have a possible workaround?

No - that won’t be a solution - as that only affects how the software spi support (not used since you are driving ucs1903s).

It will still be at least another week before I can put any serious time into this one.