Moin Moin
Ich hatte dieses Thema schon einmal im Mini-Z Forum angesprochen. Leider konnte mir nur zum Teil geholfen werden
Ich benutze den unten aufgeführten Sketch. Die RX Lampe auf dem Arduino Board läuft synchron zur Software. Dort wird eine Startampel angezeigt und diese soll wiederrum über ein ArduinoR3 angesteuert werden.
Nun ist mein Problem, dass die Adafruit NEO Pixel nicht angesprochen wird. Warum auch immer ?
Ich habe die Adafruit NEO Pixel ( 60 LED´s ) mit 5 Volt 3 A zusätzlich versorgt. Laut dem Sketch soll ich das Signalkabel an PIN 6 anlegen. Habe ich auch so gemacht. Zusätzlich habe ich GND von der NEO Pixel mit dem Board GND verbunden.
Hier der Sketch
//==============================================================================
// Program: ZRound_ws2811.ino
// Author: Hernan Jardon
// Target: UNO R3, IDE 1.6.5
// Date: 2015/07/21
// Time: 16:08
// Notes:
// Uses Serial I/O
// Reference: MODIFICACION CODIGO Juan Pardo, adaptacion LEDSTRIP WS-2811
//==============================================================================
#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme;
float temperature, humidity;
char Tstr[10];
char Hstr[10];
char sendbuffer[62];
uint16_t messintervall = 120000;
unsigned long nextmeasurement = 0;
unsigned long currentloop = 0;
#define PIN 6 // PIN DE CONEXION
#define VERSION 0.7
//=====[ CONSTANTS ]============================================================
#define CMD_START "$START"
#define CMD_STOP "$STOP"
#define ANS_GO "$GO"
#define bSize 64
#define L_OFF HIGH
#define L_ON LOW
//=====[ PINS ]=================================================================
int DebugLed = 13;
//=====[ VARIABLES ]============================================================
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
char Buffer[bSize]; // Serial buffer
char ShadowBuffer[bSize]; // Serial buffer
char Command[10];
byte max_lights = 7; // MAX DE LEDS EN TIRA
uint32_t blinking_color_1 = strip.Color(255, 255, 0); //AMARILLO
uint32_t blinking_color_2 = strip.Color(255, 0, 0); //ROJO
byte secuencia_de_encendido[]={2,3,4,5,6,7}; //ORDEN ENCENDIDO
uint32_t colores_por_bloque[]={ strip.Color(255, 0, 0), //1-Rojo
strip.Color(255, 0, 0), //2-Rojo
strip.Color(255, 0, 0), //3-Rojo
strip.Color(255, 0, 0), //4-Rojo
strip.Color(255, 255, 0), //5-Amarillo
strip.Color(255, 255, 0)}; //6-Amarillo
byte bloques_de_led = 6;
byte cantidad_de_led_por_bloque =1; // CARTIDAD DE LEDS POR BLOQUE
//=====[ ReadSerialCommand ]====================================================
int ReadSerialCommand(void) {
int BytesCount = -1;
BytesCount = Serial.readBytesUntil('\n',Buffer,bSize-1);
if (BytesCount > 0) {
Buffer[BytesCount]='\0';
}
else{
Buffer[0]='\0';
}
return BytesCount;
}
//=====[ Lights ]=============================================================
void LightsOFF(void) {
uint32_t c = strip.Color(0, 0, 0);//Negro
for(int i=2; i<=bloques_de_led+1; i++){
for(int j=0; j<cantidad_de_led_por_bloque; j++){
int num = ((i-1)*cantidad_de_led_por_bloque )+ j;
if(num < max_lights ){
strip.setPixelColor(num, c);
}
}
}
strip.show();
}
void LightsON(uint32_t c) {
for(int i=2; i<=bloques_de_led+1; i++){
for(int j=0; j<cantidad_de_led_por_bloque; j++){
int num = ((i-1)*cantidad_de_led_por_bloque )+ j;
if(num < max_lights){
strip.setPixelColor(num, c);
}
}
}
strip.show();
}
//=====[ SETUP ]===============================================================
void setup() {
strip.begin();
Serial.begin(9600);
delay(100);
bme.begin(0x76);
pinMode(LED_BUILTIN, OUTPUT);
delay(100);
LightsOFF();
}
//=====[ LOOP ]===============================================================
void loop() {
currentloop = millis();
if (nextmeasurement < currentloop) {
digitalWrite(LED_BUILTIN, HIGH);
temperature = bme.readTemperature();
humidity = bme.readHumidity();
dtostrf(temperature, 3, 2, Tstr);
dtostrf(humidity, 3, 2, Hstr);
sprintf(sendbuffer, "$HS,%s\n", Hstr);
Serial.println(sendbuffer);
delay(200);
sprintf(sendbuffer, "$TS,%s\n", Tstr);
Serial.println(sendbuffer);
nextmeasurement = currentloop + messintervall;
digitalWrite(LED_BUILTIN, LOW);
}
if(ReadSerialCommand()>0){
strcpy(ShadowBuffer,Buffer);
strcpy(Command,strtok(ShadowBuffer,","));
if(strcmp(Command, CMD_START)==0){
LightsOFF();
for(int i=0; i<bloques_de_led; i++){
int bloque = secuencia_de_encendido[i];
uint32_t c = colores_por_bloque[i];
for(int j=0; j<cantidad_de_led_por_bloque; j++){
int num = ((bloque-1)*cantidad_de_led_por_bloque )+ j;
if(num < max_lights ){
strip.setPixelColor(num, c);
}
}
strip.show();
delay(1000);
}
// Send GO to PC
Serial.print(ANS_GO);
Serial.print('\n');
Serial.flush();
LightsON(strip.Color(0, 255, 0)); //VERDE
delay(5000);
LightsOFF();
}else if(strcmp(Command, CMD_STOP)==0){
LightsOFF();
// Red lights blinking during 30 Seconds
for(int i=0;i<30;i++){
LightsON(blinking_color_1 );
delay(500);
LightsON(blinking_color_2 );
delay(500);
}
LightsOFF();
}
}
}
Und hier ein Bild zur Software Z-Round. Diese soll das Arduino Board ansprechen.
Diese LED nutze ich
"NeoPixel"-LED-Strip (WS2812B)
Könnte mir einer bei der Verkabelung helfen und sich evtl. mal den Sketch anschauen ?
Der Sketch sollte ja eigentlich so funktionieren.
Bin für jede Hilfe dankbar.
Gruß