Bjr @ ts,
Je ne pouvais les mettre dans le post précédent et j'en avais crée un autre mais il na pas du être enregistré.
En fait je vais devoir le faire en deux car les 2 codes dépassent le nombre de caractères dont j'ai droit
Du coup, les voici:
Je sais que j'y ai mis pas mal de "Serial.print", mais ils sont provisoires, c'est pour moi pour essayer de comprendre ce qui se passe.
Le 1er code: reception_donnees_2_9
char caracter;
String DonneesRecu;
String red;
String green;
String blue;
String brightness;
String ValBouton;
int ind1;
int ind2;
int ind3;
int ind4;
int ind5;
int roLed;
int veLed;
int blLed;
int lumLed;
int FctBouton;
// Necessaire pour bluetooth
#include <SoftwareSerial.h>
#include <Wire.h>//Include libraries: SoftwareSerial & Wire
SoftwareSerial Bluetooth(10,11); //Define PIN10 & PIN11 as RX and TX pins
// Necessaire pour bandeau led
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
#include <FastLED.h>
#define BRIGHTNESS 200
#define FRAMES_PER_SECOND 120
#define LED_PIN 6
#define LED_PIN2 5
#define LED_COUNT 41
#define LED_COUNT2 41
struct CRGB leds[LED_COUNT];
struct CRGB leds2[LED_COUNT2];
CRGBPalette16 gPal;
// FOR SYLON ETC
uint8_t thisbeat = 23;
uint8_t thatbeat = 28;
uint8_t thisfade = 2; // How quickly does it fade? Lower = slower fade rate.
uint8_t thissat = 255; // The saturation, where 255 = brilliant colours.
uint8_t thisbri = 255;
int myhue = 0;
// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip = Adafruit_NeoPixel(41, LED_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(41, LED_PIN2, NEO_GRBW + NEO_KHZ800);
void setup() {
delay(3000);
Serial.begin(9600);
Bluetooth.begin(9600);
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(200); // Set BRIGHTNESS to about 1/5 (max = 255)
strip2.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip2.show(); // Turn OFF all pixels ASAP
strip2.setBrightness(200);
}
uint8_t gHue = 0;
void loop() {
if(Bluetooth.available()) {
caracter = Bluetooth.read();
DonneesRecu = DonneesRecu + caracter;
if(caracter == '*') {
DonneesRecu = DonneesRecu.substring(0, DonneesRecu.length() - 1); // Delete last char *
Serial.print("données reçues = ");
Serial.println(DonneesRecu);
ind1 = DonneesRecu.indexOf(',');
red = DonneesRecu.substring(0, ind1);
roLed = red.toInt();
ind2 = DonneesRecu.indexOf(',', ind1+1 );
green = DonneesRecu.substring(ind1+1, ind2);
veLed = green.toInt();
ind3 = DonneesRecu.indexOf(',', ind2+1 );
blue = DonneesRecu.substring(ind2+1, ind3);
blLed = blue.toInt();
ind4 = DonneesRecu.indexOf(',', ind3+1 );
brightness = DonneesRecu.substring(ind3+1, ind4);
lumLed = brightness.toInt();
ind5 = DonneesRecu.indexOf(',', ind4+1 );
ValBouton = DonneesRecu.substring(ind4+1);
FctBouton = ValBouton.toInt();
//Serial.print("red = ");
//Serial.println(red);
//Serial.print("green = ");
//Serial.println(green);
//Serial.print("blue = ");
//Serial.println(blue);
//Serial.print("brightness = ");
//Serial.println(brightness);
Serial.print("valeur rouge = ");
Serial.println(roLed);
Serial.print("valeur verte = ");
Serial.println(veLed);
Serial.print("valeur bleu = ");
Serial.println(blLed);
Serial.print("valeur luminosite = ");
Serial.println(lumLed);
Serial.print("valeur Fct Bouton = ");
Serial.println(FctBouton);
Serial.println();
DonneesRecu = "";
delay(10);
if (FctBouton == 1) {
strip.setBrightness(lumLed);
couleurDemandee();
}
else if (FctBouton == 2) {
strip2.setBrightness(lumLed);
couleurDemandee2();
}
else if (FctBouton == 3) {
strip.setBrightness(lumLed);
rainbow3(20);
}
else if (FctBouton == 4) {
strip.setBrightness(lumLed);
colorWipe((roLed, veLed, blLed), 50);
}
}
}
}
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
void colorWipe2(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip2.numPixels(); i++) {
strip2.setPixelColor(i, c);
strip2.show();
delay(wait);
}
}
void couleurDemandee() {
strip.setBrightness(lumLed);
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(roLed, veLed, blLed) );
}
delay(50);
strip.show();
}
void couleurDemandee2() {
strip2.setBrightness(lumLed);
for(uint16_t i=0; i<strip2.numPixels(); i++) {
strip2.setPixelColor(i, strip2.Color(roLed, veLed, blLed) );
}
delay(50);
strip2.show();
}
void rainbow()
{
// FastLED's built-in rainbow generator
fill_rainbow( leds, LED_COUNT, gHue, 7);
}
void sinelon()
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, LED_COUNT, 20);
int pos = beatsin16( 13, 0, LED_COUNT-1 );
leds[pos] += CHSV( gHue, 255, 192);
// send the 'leds' array out to the actual LED strip
FastLED.show();
// insert a delay to keep the framerate modest
FastLED.delay(1000/FRAMES_PER_SECOND);
EVERY_N_MILLISECONDS( 20 ) { gHue++; }
}
void confetti()
{
// random colored speckles that blink in and fade smoothly
fadeToBlackBy( leds, LED_COUNT, 10);
int pos = random16(LED_COUNT);
leds[pos] += CHSV( gHue + random8(64), 200, 255);
}
void juggle() {
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds, LED_COUNT, 20);
byte dothue = 0;
for( int i = 0; i < 8; i++) {
leds[beatsin16( i+7, 0, LED_COUNT-1 )] |= CHSV(dothue, 200, 255);
dothue += 32;
}
}
void rainbow2(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i*1+j) & 255));
}
strip.show();
delay(wait);
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
if(WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
void rainbow3(int wait) {
// Hue of first pixel runs 3 complete loops through the color wheel.
// Color wheel has a range of 65536 but it's OK if we roll over, so
// just count from 0 to 3*65536. Adding 256 to firstPixelHue each time
// means we'll make 3*65536/256 = 768 passes through this outer loop:
for(long firstPixelHue = 0; firstPixelHue < 3*65536; firstPixelHue += 256) {
for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
// Offset pixel hue by an amount to make one full revolution of the
// color wheel (range of 65536) along the length of the strip
// (strip.numPixels() steps):
int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
// strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or
// optionally add saturation and value (brightness) (each 0 to 255).
// Here we're using just the single-argument hue variant. The result
// is passed through strip.gamma32() to provide 'truer' colors
// before assigning to each pixel:
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
}
strip.show(); // Update strip with new contents
delay(wait); // Pause for a moment
}
}
Encore merci par avance si vous pouvez m'aider
@mitiés @ ts