<< return to Pixycam.com

Interference with other connected components


I am working on a project that has an Arduino performing two different tasks along side each other. One, of course, is controlling and getting data from a Pixy2, and the other is controlling a strip of Adafruit NeoPixels. Both sides of the code work fine when run separately, but when run along side each other, the Pixy2 somehow interferes with the NeoPixels causing pixels to turn colors they are not supposed to.

I have narrowed it down some and figured out that the interference only occurs when data is transferred between the Arduino and the Pixy2. The function that updates the NeoPixels is show().

Interestingly, the colors that the pixels turn (but are not supposed to) are very consistent based on what the Pixy2 is doing.

Thanks in advance for any help!

NeoPixel Arduino library downloads: https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-installation
NeoPixel Arduino library use: https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-use


Please describe how you are controlling the Neopixels and Pixy2. That is, which types of serial ports you are using for each.



I am using the on-board ICSP port (Arduino uno/nano) for the Pixy2 and one digital pin for the NeoPixels.


Which digital pin are you using for the NeoPixels?


I use pin 6 but have tried others and it made no difference


Pin 6 isn’t in common with the ICSP port and isn’t used by Pixy. Need to avoid pins 10, 11, 12, 13 on the Uno when using Pixy because these are the same pins as the ICSP pins.

I’m guessing there is some timing-related thing going on with the neopixels. I found this:

The Pixy library doesn’t use any interrupts, although I’m guessing the SPI routines in the Arduino low-level firmware do use interrupts. This shouldn’t affect the neopixels though, because the neopixel routines disable interrupts – it could affect Pixy communication however.

I’m coming up blank as to why it would matter. (sorry)



I just thought of something…
Could it possibly be fixed by disabling all interrupts for part of the code, then re-enabling them after? (https://forum.arduino.cc/index.php?topic=40766.0)

By the way, thanks for the link. Now at least I know it’s something based on the timing of the signals and not the signals getting mixed up.


I tried disabling interrupts before updating the NeoPixels and re-enabling them after, but it didn’t make any difference. Is there any way to temporarily suspend communication with the Pixy2 or SPI bus?


If you don’t call getBlocks() (or any other Pixy method), no communication will take place.


I finally got it to work, but it wasn’t the way I was expecting to fix it. Originally, I was using classes I wrote for the Pixy2 and NeoPixels. As part of my troubleshooting, I made a copy of the project, but with everything in one file, and it worked! Not sure why that fixed it though… :confused: