Problem mit der selbst erstellten Klasse


hallo,

ich hätte da mal ein problem und zwar ich mit den arduino nano rgb leds mit ws2812 chip steuern. um das programm kurz zu halten habe ich mir eine klasse mit der entsprechende funktion erstellt. der compiler selber erkennt bei den code keinen fehler und lässt sich der code auch ohne problem auf den arduino drauf spielen, doch leider passiert denn nichts. mein alternativer code ohne klasse mit derselben pin-belegung funktioniert ohne problem.

ich hatte vorher auch schon problem wo ich erst das array erstellt habe und anschließend befüllen wollte, deshalb ist das als kommentar ausgegraut.

wenn einer hier eine idee hätte wo der fehler liegt, würde ich mich freuen, da es mir hierbei das problem sich geht.

ich sage schon mal danke und wünsche euch allen hier ein schönes restwochenende.

mfg



#include <adafruit_neopixel.h>
#define pin         6
#define numpixels   7

adafruit_neopixel pixels = adafruit_neopixel(numpixels, pin, neo_grb + neo_khz800);

class farbe
{
private:
  int a;
  int b;
  int c;

public:
  farbe (int aa, int bb, int cc) : a(aa), b(bb), c(cc) {}

void setfarbe ( )
{
     
      pixels.begin();
      pixels.setpixelcolor(0,pixels.color (a, b, c));
      pixels.setpixelcolor(1,pixels.color (a, b, c));
      pixels.setpixelcolor(2,pixels.color (a, b, c));
      pixels.setpixelcolor(3,pixels.color (a, b, c));
      pixels.setpixelcolor(4,pixels.color (a, b, c));
      pixels.setpixelcolor(5,pixels.color (a, b, c));
      pixels.setpixelcolor(6,pixels.color (a, b, c));
      pixels.show();
 
  }
 
};

void setup() {

  int time = 3000;

  farbe a[3] = {{255,  0,  0}, {255,165,  0}, {255,255,  0} };

  /*
  farbe a[7];
  a[0]   =  (255,  0,  0);
  a[1]   =  (255,165,  0);
  a[2]   =  (255,255,  0);
  a[3]   =  (127,255,  0);
  a[4]   =  (  0,191,255);
  a[5]   =  ( 75,  0,130);
  a[6]   =  (238,130,238);
*/

  (int = 0; i++ ; < 7)
  {

    a.setfarbe ();
   
    delay (time);
     

  }
}

void loop() {
  // put main code here, run repeatedly:

}

setze deinen code bitte in codetags (</> oben links im editor).

ich kann hier keine klassendefinition sehen.

gruß tommy


Arduino Forum > International > Deutsch (Moderator: uwefed) > Problem mit der selbst erstellten Klasse


arduino

Comments

Popular posts from this blog

Error compiling for board Arduino/Genuino Uno.

Installation database is corrupt

esp8266 (nodemcu 0.9) client.write très lent ???