Neopixels with RT1062

I’m looking for a light source for the RT1062 and thought that the 12 neopixel ring I had laying around might be a good option. I saw there was a neopixel MicroPython library and it was on the RT1062, but the test code that I wrote did not light up the ring. I saw some older posts about the neopixels not working (well?) with the OpenMV cameras, but I thought maybe the newer one might support them. Here is my test code:

import sensor
import time
import neopixel

from machine import Pin

pin = Pin('P7', Pin.OUT)

n = neopixel.NeoPixel(pin,12)

sensor.reset()  # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE)  # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.XGA)  # Set frame size to QVGA (320x240)
sensor.skip_frames(time=2000)  # Wait for settings take effect.
clock = time.clock()  # Create a clock object to track the FPS.

while True:

    n = neopixel.NeoPixel(pin,12)
    for i in range(12):
        n[i] = (255, 255, 255)
    n.write()

    clock.tick()  # Update the FPS clock.
    img = sensor.snapshot()  # Take a picture and return the image.
    print(clock.fps())  # Note: OpenMV Cam runs about half as fast when connected
    # to the IDE. The FPS should increase once disconnected.

If nexopixels won’t work, do you have any suggestion for a light source that won’t have too much shadowing?

Yeah, so, for neopixels those require precise timing which conflicts with our interrupt driven dma system. However, it should work when that is not running.

Try to control the LEDs before doing anything with sensor. It should work.

That did the trick, by placing the “write” code prior to everything else before the while loop, I was able to active the neopixels and use them as illumination as desired. Thanks for your assistance.

Just out of curiosity, would this also work on the H7 Plus?

Yes, the H7 Plus has full DMA hardware offload too so the CPU gets less interrupts.