Javadoc link

Neo Pixel is a chainable, addressable strips of leds hardware controllable using only one signal wire.  The NeoPixel service will allow you to connect and control the Neo Pixel strip connected to an Arduino with MyRobotLab (MRL).

The NeoPixel hardware can connect to any pins on the arduino board, including analog pins

Note: Neo Pixel hardware can draw a lot of power (60mA for each pixels at full brightness). If you are running a large set of LEDs, you should power it with external power source instead of the Arduino.

Hardware:

References:

 

 

Example code (from branch develop):
#########################################
# NeoPixel.py
# more info @: http://myrobotlab.org/service/NeoPixel
#########################################
# Example of controlling a NeoPixel
# NeoPixel is a strip of RGB LEDs
# in this example we are using a 256 pixel strip
# and an Arduino Mega.
# The Mega is connected to the NeoPixel strip
# via pin 3
# The Mega is connected to the computer via USB
# Onboard animations are available
# as well as the ability to set individual pixels
# [Stop, Theater Chase Rainbow, Rainbow, Larson Scanner, Flash Random,
# Theater Chase, Rainbow Cycle, Ironman, Color Wipe]
# There are now pre defined flashes which can be used
# [warn, speaking, heartbeat, success, pir, error, info]
 
from time import sleep
 
port = "/dev/ttyACM72"
pin = 3
pixelCount = 256
 
# starting mega
mega = runtime.start("mega", "Arduino")
mega.connect(port)
 
# starting neopixle
neopixel = runtime.start("neopixel", "NeoPixel")
neopixel.setPin(pin)
neopixel.setPixelCount(pixelCount)
 
# attach the two services
neopixel.attach(mega)
 
# brightness 0-255
neopixel.setBrightness(128)
 
# fuschia - setColor(R, G, B)
neopixel.setColor(120, 10, 30)
 
# Fun with flashing
print(neopixel.getFlashNames())
 
for flash in neopixel.getFlashNames():
    print('using flash', flash)
    neopixel.flash(flash)
 
# clear all pixels    
neopixel.clear()
 
 
# 1 to 50 Hz default is 10
neopixel.setSpeed(10)
 
# Fun with animations
# get a list of animations
print(neopixel.getAnimations())
 
for animation in neopixel.getAnimations():
    print(animation)
    neopixel.playAnimation(animation)
    sleep(3)
 
# clear all pixels
neopixel.clear()
 
neopixel.fill("cyan")
sleep(1)
neopixel.fill("yellow")
sleep(1)
neopixel.fill("pink")
sleep(1)
neopixel.fill("orange")
sleep(1)
neopixel.fill("black")
sleep(1)
neopixel.fill("magenta")
sleep(1)
neopixel.fill("green")
sleep(1)
neopixel.fill("#FFFFEE")
sleep(1)
neopixel.fill("#FF0000")
sleep(1)
neopixel.fill("#00FF00")
sleep(1)
neopixel.fill("#0000FF")
sleep(1)
neopixel.fill("#cccccc")
sleep(1)
neopixel.fill("#cc7528")
sleep(1)
neopixel.fill("#123456")
sleep(1)
neopixel.fill("#654321")
sleep(1)
neopixel.fill("#000000")
 
# if you want voice modulation of a neopixel this is one
# way to do it
# mouth = runtime.start('mouth', 'Polly')
# audio = runtime.start('mouth.audioFile', 'AudioFile')
# audio.addListener('publishPeak', 'neopixel')
# mouth.speak('Is my voice modulating the neopixel?')
 
print('done')    
    

Tested with a deported nano and 90% worky :) Great work

( I use a nano and the script launch fine but only once. It stuck the deported arduino and need to be hand reset )

There no errors in the log after the last line : NEO_PIXEL_SET_ANIMATION

Setup :

I solder wires on RX/TX 3 onto the nervoboard ( don't use RX/TX0 !! it is usb ) to connect nano RX/TX

This is the script I use from your work :

[MRL 1803]

from time import sleep
arduino = Runtime.createAndStart("arduino","Arduino")
arduino.setBoardMega()
arduino.connect("COM4")

arduino1 = Runtime.createAndStart("arduino1","Arduino")
arduino1.setBoardNano()
arduino1.connect(arduino,"Serial3")
sleep(1)

neopixel = Runtime.createAndStart("neopixel","NeoPixel")
neopixel.attach(arduino1, 3, 16)
 
neopixel.setAnimation("Theater Chase", 255, 0, 0, 1) #running Theater Chase with color red at full speed
sleep(5)
neopixel.animationStop()

Thanks Anthony for sharing your test script.

I think the bug with the Nano has to do with the RX/TX at the Nano side...

These are still connected to the FTDI chip onboard !

I will use a Arduino Pro Mini board, this one is without a onboard FTDI chip.

 

Here a view to the updated NervoBoard:

Regards,

Marten

So the script above gets loaded onto the Nano?

which gets plugged into the USB Hub?

Thanks!

Stephen

MdG_NL

7 years 2 months ago

In reply to by mayaway

Hi Stephen,

The srcipt is Phyton based, which can run via MRL !
The Nano just need the MRLComm.ino sketch to communicate with MRL.

The script from Calamity needs a USB connection to the Nano...
And the script from Moz4r is connected via "RX / TX 3" from the Arduino Mega !
So the Mega and the Nano are connected with the same USB.
USB -> Arduino_Mega -> RX / TX 3 -> Nano

Regards,

Marten 

Hi Martin,

It makes sense that the Nano would hold the *.ino script so it would become another device that MRL could manage. I am unsure about the USB -> Arduino_Mega -> RX / TX 3 -> Nano

My plan was to use Calamity's script (I didn't know there were two, and don't know which one I have...)

I think I would load *.ino onto the Nano, then plug it in via usb to the InMoov's USB Hub -- I have the tablet, the Mega's, the Camera's, and (for now) a mouse on the hub. MRL should see the Nano (probably) on COM5 since the Mega's are showing up on 3 and 4

Does this sound right?

Thanks,

Stephen

MdG_NL

7 years 2 months ago

In reply to by mayaway

Hi Stephen,

Yes all sounds right if you like to use the Calamity *.py :)
Double check your com port number during the *.ino upload.
(You will need to select the correct com port anyway before you can upload.)

Regards,

Marten

I have v1723 with these lines

neopixel = Runtime.createAndStart("neopixel","Serial")
neopixel.connect("COM5", 57600, 6, 1, 0)
 
I have uploaded MRLComm.ino to the Arduino Nano which is powerd externally and PIN 6 feeds data to the Neo-Pixel Ring
The nano is plugged into the USB Hub
 
Gael's gestures make a call like neopixel.write(3)
 
This all sounds right?
 
 

GroG

2 years 7 months ago

This is an example of a NeoPixel named "neo" with base color RGB (212, 0, 255), pin 5, with 8 pixels attached to an Arduino controller named "mega" - it will startup, set the color and automatically run the Larson Scanner with that color.

Example configuration (from branch develop):
!!org.myrobotlab.service.config.NeoPixelConfig
autoClear: true
blue: 0
brightness: 255
controller: null
currentAnimation: null
fill: false
green: 0
idleTimeout: 1000
listeners: null
peers: null
pin: null
pixelCount: null
pixelDepth: 3
red: 0
speed: 10
type: NeoPixel