merci de ton aide, oui il s'agit bien de vixenlihgt.
mon premier programme :
/*
This sketch allows the Arduino to read 16 bytes of data from Vixen and turn on
its pins accordingly, which in turn controls a solid state relay hooked up to Xmas lights.
*/
// Define pins on Arduino that will control the relay.
#define CHANNEL_01 2
#define CHANNEL_02 3
#define CHANNEL_03 4
#define CHANNEL_04 5
#define CHANNEL_05 6
#define CHANNEL_06 7
#define CHANNEL_07 8
#define CHANNEL_08 9
// Define size of array to hold channels
#define CHANNEL_COUNT 8
// Define array to hold channels
int channels[] =
{
CHANNEL_01, CHANNEL_02, CHANNEL_03, CHANNEL_04, CHANNEL_05, CHANNEL_06, CHANNEL_07, CHANNEL_08,
};
// Define array to hold incoming data stream from Vixen
int incomingByte[16];
// Define baud rate. This figure must match that of your profile configuration in Vixen!
#define BAUD_RATE 115200
void setup()
{
// Begin serial communication
Serial.begin(BAUD_RATE);
// Set up each channel as an output
for(int i = 0; i < CHANNEL_COUNT; i++)
{
pinMode(channels[i], OUTPUT);
}
}
void loop()
{
if (Serial.available() >= CHANNEL_COUNT)
{
// Read data from Vixen, store in array
for (int i = 0; i < CHANNEL_COUNT; i++)
{
incomingByte[i] = Serial.read();
}
// Write data from array to a pin on Arduino
for (int i = 0; i < CHANNEL_COUNT; i++)
{
digitalWrite(channels[i], incomingByte[i]);
}
}
}
mon deuxième :
/*
Vixen Lights 3.x - Arduino Generic Serial for Addressable Pixels
Using this code is pretty straight forward, simply hookup your one wire (WS2811 or WS2812) data line to pin 6 of your Arduino
and upload this code. Make sure you have properly installed the FastLED library from http://fastled.io Once you are done, simply
power your Pixel strips from an external power supply. Next configure a Generic Serial Controller inside of Vixen Lights 3.x and
add 3 x pixels for the number of channels. Configure the Generic Serial Controller to use 115200, 8, none, and 1. Then create
your element and add "Multiple Items (1 x number of pixels). Finally select your pixel elements and set them as RGB pixels before
patching them to the controler outputs. You should now be ready to begin testing.
For a complete tutorial check out blog.huntgang.com
Created November 8th, 2014
By Richard Sloan - www.themindfactory.com
And David Hunt - blog.huntgang.com
Version 1.4
*/
// You must download and install the library from http://fastled.io/
#include <FastLED.h>
// Sets the maximum number of LEDs that this code will handle to avoid running out of memory
#define NUM_LEDS 299
// Sets the pin which is used to connect to the LED pixel strip
#define DATA_PIN 10
CRGB leds[NUM_LEDS];
void setup() {
// Define the speed of the serial port
Serial.begin(115200);
}
void loop() {
// Set some counter / temporary storage variables
int cnt;
unsigned int num_leds;
unsigned int d1, d2, d3;
// Begin an endless loop to receive and process serial data
for(;
{
// Set a counter to 0. This couter keeps track of the pixel colors received.
cnt = 0;
//Begin waiting for the header to be received on the serial bus
//1st character
while(!Serial.available());
if(Serial.read() != '>') {
continue;
}
//second character
while(!Serial.available());
if(Serial.read() != '>') {
continue;
}
//get the first digit from the serial bus for the number of pixels to be used
while(!Serial.available());
d1 = Serial.read();
//get the second digit from the serial bus for the number of pixels to be used
while(!Serial.available());
d2 = Serial.read();
//get the third digit from the serial bus for the number of pixels to be used
while(!Serial.available());
d3 = Serial.read();
//get the end of the header
while(!Serial.available());
if(Serial.read() != '<') {
continue;
}
while(!Serial.available());
if(Serial.read() != '<') {
continue;
}
// calculate the number of pixels based on the characters provided in the header digits
num_leds = (d1-'0')*100+(d2-'0')*10+(d3-'0');
// ensure the number of pixels does not exceed the number allowed
if(num_leds > NUM_LEDS) {
continue;
}
// Let the FastLED library know how many pixels we will be addressing
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, num_leds);
// Loop through each of the pixels and read the values for each color
do {
while(!Serial.available());
leds[cnt].r = Serial.read();
while(!Serial.available());
leds[cnt].g = Serial.read();
while(!Serial.available());
leds[cnt++].b = Serial.read();
}
while(--num_leds);
// Tell the FastLED Library it is time to update the strip of pixels
FastLED.show();
// WOO HOO... We are all done and are ready to start over again!
}
}
les deux fonctionnent individuellement, j'ai regroupé les lignes et ça ne fonctionne pas.