This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

  • 0 voto(s) - 0 Media
  • 1
  • 2
  • 3
  • 4
  • 5
CONSULTA problemas en codigo
#1
Hola buenas, soy nuevo con arduino, estoy tratando de programar una tira led WS2812B de 30 leds, utilizando una placa arduino uno con las librerias adafruit-neopixel y fastled, pero el código me sigue tirando error, me podrían ayudar???

dejo el codigo:


void loop() {
  Fire(55,120,15);
}

void Fire(int Cooling, int Sparking, int SpeedDelay) {
  static byte heat[30];
  int cooldown;
 
  // Step 1.  Cool down every cell a little
  for( int i = 0; i < 30; i++) {
    cooldown = random(0, ((Cooling * 10) / 30) + 2);
   
    if(cooldown>heat[i]) {
      heat[i]=0;
    } else {
      heat[i]=heat[i]-cooldown;
    }
  }
 
  // Step 2.  Heat from each cell drifts 'up' and diffuses a little
  for( int k= 30 - 1; k >= 2; k--) {
    heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;
  }
   
  // Step 3.  Randomly ignite new 'sparks' near the bottom
  if( random(255) < Sparking ) {
    int y = random(7);
    heat[y] = heat[y] + random(160,255);
    //heat[y] = random(160,255);
  }

  // Step 4.  Convert heat to LED colors
  for( int j = 0; j < 30; j++) {
    setPixelHeatColor(j, heat[j] );
  }

  showStrip();
  delay(SpeedDelay);
}

void setPixelHeatColor (int Pixel, byte temperature) {
  // Scale 'heat' down from 0-255 to 0-191
  byte t192 = round((temperature/255.0)*191);
 
  // calculate ramp up from
  byte heatramp = t192 & 0x3F; // 0..63
  heatramp <<= 2; // scale up to 0..252
 
  // figure out which third of the spectrum we're in:
  if( t192 > 0x80) {                     // hottest
    setPixel(Pixel, 255, 255, heatramp);
  } else if( t192 > 0x40 ) {             // middle
    setPixel(Pixel, 255, heatramp, 0);
  } else {                               // coolest
    setPixel(Pixel, heatramp, 0, 0);
  }
}
  Responder
#2
Buenas noches.

Como ya he dicho hoy en otra publicación, he estado bastante liado con el trabajo y no he podido ver esta publicación antes, espero que no sea demasiado tarde para ayudarte.

No has dejado el código, has copiado un trozo del código, que no es lo mismo, si no pones la parte de arriba donde incluyes las librerías y defines las variables, NO PUEDO HACER NADA para ayudarte. Todo lo que esta antes del void loop()

Un saludo
  Responder


Posibles temas similares…
Tema Autor Respuestas Vistas Último mensaje
  CONSULTA Saludos - Problema con código Alexeim56 2 797 29-03-2021, 09:59 PM
Último mensaje: asesorplaza1
  CONSULTA ¿como uno dos codigos en un solo codigo? laurangcard 1 943 18-11-2020, 10:03 PM
Último mensaje: asesorplaza1
  error al compilar el código homer32 4 1,984 23-09-2019, 01:29 PM
Último mensaje: homer32
  CONSULTA Codigo pluviometro balancin Dieseldj1 0 943 01-09-2019, 10:43 PM
Último mensaje: Dieseldj1
  conversión código arduino ethernet 5100 a wemos d1 mini nbaglietto 0 1,377 24-11-2017, 02:05 AM
Último mensaje: nbaglietto