Most builders of the InMoov robot have eventually installed the NeoPixel ring with 16 Pixels in the stomach.
When working, these little multi colored LED unit can look very impressive.\
As Part of Fred's program, I also wanted to use these marvelous devices.
Of course I had to be different :-) and add extra NeoPixels to the ring.
For this I added a 7 pixel button to the middle of the 16 pixel ring giving a total of 23 pixels.
The Dout of the 16 pixel ring is connected to the Din of the 7 pixel button.
To make sure there was enough power I also added a XL4005 DC-DC buck SMPS rated at 4 Amps.
I'll add al link to the video when it's released :-)
 
The Din of the 16 Pixel ring was connected to D8 of the Arduino Nano located in Fred's chest.
This Arduino also controls two Ultra Sonic range sensors D9 - D12 and a single PIR sensor on D2
 
Running with MRL_Nixie installed on a Raspberry Pi 4 with 8GB or RAM running Raspbian Buster 32Bit.
 
The full source code for Fred can be found here:
 
First thing I did was configure the settings I will be using for the NeoPixels.
 
EnableStomachNeoPixel = True
StomachNeoPixelAttachment = "arduinoNano"   # This was attached to a secondary board
StomachNeoPixelPin = 8                      # 2
StomachNeoPixelNumber = 23                  # 16
StomachNeoPixelMode = 0                     # This is how we will use the Neopixel ring/s
 
Next we start the service for the NeoPixels
Because I want to have different modes of operation, I defined the StomachNeoPixelMode.
Mode 0 will be used as a user configurable diagnostic mode of sorts
For now the other modes are just running the built in animations.
Before I can use the user configurable diagnostic mode, I first have to configure it :-)

 

 
Once this is all configured, we can run the section of program that runs the NeoPixels.

 

This program works, but here are a few little bugs and traps to be aware of and how to work around them :-)
 
  • First of the bugs,
    NeoPixel.writeMatrix() is supposed to write all the NeoPixels that were set by the NeoPixel.setPixel(Addr, R, G, B).
    The theory is you can set a number of pixels, then write the lot out in one go.
    This does not work.  The results will be most of the pixels being turned off and a random pixel or two being set to the desired color.
    The work around is the call the NeoPixel.writeMatrix() after each NeoPixel.setPixel(Addr, R, G, B).
     
  • Once you have started an Animation with NeoPixel.setAnimation(Animation Name", red, green, blue, speed) Don't call the command again.
    A call to the same command will reset the animation back to the start of it's sequence. 
    This is not a bug, but you do need to be aware of this when you have a timer poling your NeoPixel routines :-)
     
  • When switching back to setPixel method of operation, remember to first stop the animation.
    Use the NeoPixel.animationStop(), but don't keep calling it, it will keep clearing all your pixels back to off. :-)
     
  • If you had been using the setPixel method before starting an animation, then stop the animation, the NeoPixel.setPixel(Addr, R, G, B) remembers that last setting you used and will not update the setting un less it's changed.
    That means if you had a pixel set to  (10, 0, 0) after the animation has been stopped, setting this color again will not turn it back on.
    The work around is to set all the pixels to a preset value writing each one out then setting each one to off again writing the setting out for each pixel.
    After that each pixel will work as expected.
 
These can be a fun device to work with and can be used to show your robots mood or status.
 
Don't forget to have fun building :-)
 

GroG

3 years 4 months ago

Great post Ray,
Informative and well written.  I'll be playing with neopixels soon too.
I a couple 8 strips I have a purpose for ..

and I'm also strategizing how to not have code copy/pasted in posts - always better to have references to code in a repo with syntax highlighting ...

I was looking into "gists"  from github, it looks promising, but haven't tested anything yet.

you've inspired me to hook one up here too.. every robot needs it's own arc-reactor looking thing-a-ma-bob.