#7753
laurent
Participant

Bonjour Anthony, oui cela ressemble plus à ce que je recherche neopixel sur activaTor, sera dans un deuxième temps, donc d’après ce que tu m’envoies, je vais monter ma nano, en Slave sur ma Mega, par contre sur le lien que tu ma donner, je vois que la carte Nervo, est une version 2, je ne savais même pas qu’elle existée, et donc sur cette carte nervo V2, il y a bien un emplacement marquer, pour le neopixel, le truc c’est que moi visiblement j’ai le kit nervo version 1(carte verte) sans indication de branchement neopixel .( ,Peux-tu m’orienter là-dessus?)
et en ce qui concerne le script, qui se trouve dans service /neopixel psy moi j’ai ceci
# ##############################################################################
# *** MRL SERVICE – NEOPIXEL ***
# ##############################################################################

#TODO ADD PIXEL MATRIX

#Animations;
#”Color Wipe”
#”Larson Scanner”
#”Theater Chase”
#”Theater Chase Rainbow”
#”Rainbow”
#”Rainbow Cycle”
#”Flash Random”
#”Ironman” > bug ?

#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)
## optional : PlayNeopixelAnimation(“Animation Name”, red, green, blue, speed, duration) > animation timeout, if neopixel exist

# ##############################################################################
# PERSONNAL PARAMETERS
# ##############################################################################

#read current service part config based on file name
ThisServicePart=inspect.getfile(inspect.currentframe()).replace(‘.py’,”)

CheckFileExist(ThisServicePart)
ThisServicePartConfig = ConfigParser.ConfigParser()
ThisServicePartConfig.read(ThisServicePart+’.config’)
isNeopixelActivated=0
try:
isNeopixelActivated=ThisServicePartConfig.getboolean(‘MAIN’, ‘isNeopixelActivated’)
masterArduinoPort=ThisServicePartConfig.get(‘MAIN’, ‘NeopixelMasterPort’)
pin=ThisServicePartConfig.getint(‘NEOPIXEL’, ‘pin’)
numberOfPixel=ThisServicePartConfig.getint(‘NEOPIXEL’, ‘numberOfPixel’)

#neopixel can have basic pre programmed reactions:
#TODO choose witch animation

#light green while robot booting
boot_green=ThisServicePartConfig.getboolean(‘BASIC_REACTIONS’, ‘boot_green’)
#blue while download something
downloadSomething_blue=ThisServicePartConfig.getboolean(‘BASIC_REACTIONS’, ‘downloadSomething_blue’)

error_red=ThisServicePartConfig.getboolean(‘BASIC_REACTIONS’, ‘error_red’)
except:
errorSpokenFunc(‘ConfigParserProblem’,’Neopixel.config’)
pass

# ##############################################################################
# SERVICE START
# ##############################################################################

if isNeopixelActivated==1:
neopixelArduino = Runtime.createAndStart(“neopixelArduino”,”Arduino”)
try:
masterArduino=eval(ThisServicePartConfig.get(‘MAIN’, ‘NeopixelMaster’))
neopixelArduinoIsConnected=CheckArduinos(neopixelArduino,masterArduinoPort,masterArduino)
except:
errorSpokenFunc(‘BAdrduinoChoosen’,’Neo pixel’)
isNeopixelActivated=0
neopixelArduinoIsConnected=0
pass

sleep(0.1)

neopixel = Runtime.createAndStart(“neopixel”,”NeoPixel”)
if neopixelArduinoIsConnected==True:
#Starting NeoPixel Service
neopixel.attach(neopixelArduino, pin, numberOfPixel)
talkEvent(lang_startingNeoPixel)
else:
isNeopixelActivated=0

# ##############################################################################
# SERVICE TWEAK
# ##############################################################################

#function to call to clean poweroff neopixel
def StopNeopixelAnimation():
if isNeopixelActivated==1:
neopixel.animationStop()

#function to call to play neopixel in blocking action
def PlayNeopixelAnimation(Animation_Name,red=255,green=255,blue=255,speed=1,duration=0):
if isNeopixelActivated==1:
neopixel.animationStop()
sleep(0.2)
neopixel.setAnimation(Animation_Name, red, green, blue, speed)
if duration!=0:
sleep(duration)
neopixel.animationStop()

sleep(1)
if boot_green:
PlayNeopixelAnimation(“Flash Random”, 0, 255, 0, 1)
sleep(1)

——————————————————————————————————-
puis je le remplacer directement par le srypt qu’il y a sur ton lien a savoir cela
——————————————————————————————————-

#working on version 1.0.1566 and over

from time import sleep

#Starting Arduino Service
arduino = Runtime.createAndStart(“arduino”,”Arduino”)
arduino.setBoardMega() #or arduino.setBoardUno()
arduino.connect(“COM15”)

#Starting NeoPixel Service
neopixel = Runtime.createAndStart(“neopixel”,”NeoPixel”)

#neopixel.attach(arduino, pin, number of pixel)
neopixel.attach(arduino, 29, 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()