NeoPixel

javadoc

The Neo Pixel are chainable, addressable leds hardware that can be controlled using only one signal wire.

The NeoPixel service allow you to connect and control an Neo Pixel hardware connected to an Arduino with MRL

 

Setup: 

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

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

 

Examples:


#file : service/NeoPixel.py edit raw
#########################################
# NeoPixel.py
# more info @: http://myrobotlab.org/service/NeoPixel
#########################################

# virtual = True
port = "COM3"
# optional but recommended neopixel connected on a dedicated arduino
rxtxPort = "Serial2"

# start optional virtual arduino service, used for internal test
if ('virtual' in globals() and virtual):
    virtualArduino = Runtime.start("virtualArduino", "VirtualArduino")
    virtualArduino.connect(port)
# end used for internal test

#Starting Arduino Service
arduino = Runtime.start("arduino","Arduino")
arduino.setBoardMega() #or arduino.setBoardUno()
arduino.connect(port)

#Starting NeoPixel Service
neopixel = Runtime.start("neopixel","NeoPixel")

#neopixel.attach(arduino, pin, number of pixel)
if ('virtual' in globals() and virtual):
  #Attach Neopixel to main arduino
  neopixel.attach(arduino, 2, 16)
else:
  #Starting optional RX/TX connected slave arduino and Attach Neopixel to slave arduino
  arduinoNano = Runtime.start("arduinoNano","Arduino")
  arduinoNano.setBoardNano() #or arduino.setBoardUno()
  arduinoNano.connect(arduino,rxtxPort)
  neopixel.attach(arduinoNano, 2, 16)


#Animations;
#"Color Wipe"
#"Larson Scanner"
#"Theater Chase"
#"Theater Chase Rainbow"
#"Rainbow"
#"Rainbow Cycle"
#"Flash Random"
#"Ironman"

#speed: 1-65535   1=full speed, 2=2x slower than 1, 10=10x slower than 1
#starting a animation
#neopixel.setAnimation("Animation Name", red, green, blue, speed)
neopixel.setAnimation("Theater Chase", 255, 0, 0, 1) #running Theater Chase with color red at full speed

sleep(10)
neopixel.animationStop()

#run an animation with python script
#turn off all the pixels
for pixel in range (1,neopixel.numPixel + 1):
  neopixel.setPixel(pixel, 0, 0, 0)  #setPixel(pixel, red, green, blue)
neopixel.writeMatrix() #send the pixel data to the Neopixel hardware 
for loop in range(0,10): #do 10 loop
  for pixel in range(1, neopixel.numPixel +1):
    neopixel.setPixel(pixel, 255, 0, 0) #set the pixel to red
    neopixel.writeMatrix()
    sleep(0.03) #give a bit of delay before next step
    neopixel.setPixel(pixel, 0, 0, 0) #turn off the pixel
neopixel.writeMatrix()

hairygael's picture

Great input Calamity !! I'm

Great input Calamity !!

I'm going to set that in my next script !

moz4r's picture

Tested with a deported nano

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()

MdG_NL's picture

Thanks Anthony for sharing

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

mayaway's picture

Nano

So the script above gets loaded onto the Nano?

which gets plugged into the USB Hub?

Thanks!

Stephen

MdG_NL's picture

Hi Stephen, The srcipt is

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 

mayaway's picture

Nano hookup

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's picture

Hi Stephen, Yes all sounds

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

mayaway's picture

NeoPixel Service

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?
 
 
moz4r's picture

documentation check

@hairygael @MdG_NL @Calamity

Hi Guys I don't have last nervoboard so I can't validate rx/tx pins place, can you check if I don't make mistakes please ?

https://github.com/MyRobotLab/inmoov/wiki/HOWTO-Neopixel-diagram-&-confi...

 

 

MdG_NL's picture

Looks very good and cool

@moz4r

Looks very good and cool Anthony, great work !

And the RX / TX pins are correct named in your HowTo.

 

Regards,

Marten

moz4r's picture

thank you Marten !

thank you Marten !