invalid conversion from 'int' to 'const int*' [-fpermissive]

Hi

Ich baue eine Wörteruhr und habe dafür diesen Code geschrieben:

const int wort_1[]={99,100};  //ES
const int wort_2[]={102,103,104};  //IST
const int wort_3[]={106,107,108,109};  //FÜNF
const int wort_4[]={98,97,96,95};  //ZEHN
const int wort_5[]={94,93,92,91,90,89,88};  //ZWANZIG
const int wort_6[]={81,82,83,84,85,86,87};  //VIERTEL
const int wort_7[]={76,75,74};  //VOR
const int wort_8[]={69,68,67,66};  //NACH
const int wort_9[]={55,56,57,58};  //HALB
const int wort_10[]={60,61,62}; //ELF
const int wort_11[]={62,63,64,65}; //FÜNF
const int wort_12[]={54,53,52,51}; //EINS
const int wort_13[]={47,46,45,44}; //ZWEI
const int wort_14[]={33,34,35,36}; //DREI
const int wort_15[]={40,41,42,43}; //VIER
const int wort_16[]={32,31,30,29,28}; //SECHS
const int wort_17[]={25,24,23,22}; //ACHT
const int wort_18[]={11,12,13,14,15,16}; //SIEBEN
const int wort_19[]={17,18,19,20,21}; //ZWÖLF
const int wort_20[]={10,9,8,7}; //ZEHN
const int wort_21[]={7,6,5,4}; //NEUN
const int wort_22[]={2,1,0}; //UHR


const int zeit_1m[]={};
const int zeit_2m[]={};
const int zeit_3m[]={5,25,35,55};
const int zeit_4m[]={10,50};
const int zeit_5m[]={20,40};
const int zeit_6m[]={15,45};
const int zeit_7m[]={25,40,45,50,55};
const int zeit_8m[]={5,10,15,20,35};
const int zeit_9m[]={25,30,35};
const int zeit_10m[]={};
const int zeit_11m[]={};
const int zeit_12m[]={};
const int zeit_13m[]={};
const int zeit_14m[]={};
const int zeit_15m[]={};
const int zeit_16m[]={};
const int zeit_17m[]={};
const int zeit_18m[]={};
const int zeit_19m[]={};
const int zeit_20m[]={};
const int zeit_21m[]={};
const int zeit_22m[]={0};


const int zeit_1h[]={};
const int zeit_2h[]={};
const int zeit_3h[]={};
const int zeit_4h[]={};
const int zeit_5h[]={};
const int zeit_6h[]={};
const int zeit_7h[]={};
const int zeit_8h[]={};
const int zeit_9h[]={};
const int zeit_10h[]={11,23};
const int zeit_11h[]={5,17};
const int zeit_12h[]={1,13};
const int zeit_13h[]={2,14};
const int zeit_14h[]={3,15};
const int zeit_15h[]={4,16};
const int zeit_16h[]={6,18};
const int zeit_17h[]={8,20};
const int zeit_18h[]={7,19};
const int zeit_19h[]={12,0,24};
const int zeit_20h[]={10,22};
const int zeit_21h[]={9,21};
const int zeit_22h[]={};


const int* zeit_m[]={5, 25, 35, 55, 10, 50, 20, 40, 15, 45, 25, 40, 45, 50, 55, 5, 10, 15, 20, 35, 25, 30, 35};
const int* zeit_h[]={11, 23, 5, 17, 1, 13, 2, 14, 3, 15, 4, 16, 6, 18, 8, 20, 7, 19, 12, 0, 24, 10, 22, 9, 21};
const int* wort_LEDs_m[]={wort_3, wort_3, wort_3, wort_3, wort_4, wort_4, wort_5, wort_5, wort_6, wort_6, wort_7, wort_7, wort_7, wort_7, wort_7, wort_8, wort_8, wort_8, wort_8, wort_8, wort_9, wort_9, wort_9};
const int* wort_LEDs_h[]={wort_10, wort_10, wort_11, wort_11, wort_12, wort_12, wort_13, wort_13, wort_14, wort_14, wort_15, wort_15, wort_16, wort_16, wort_17, wort_17, wort_18, wort_18, wort_19, wort_19, wort_19, wort_20, wort_20, wort_21, wort_21};


int Anzahlwoerter = 22;


#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

const char *ssid     = "Glattalp";
const char *password = "toedel99%";

WiFiUDP ntpUDP;

NTPClient timeClient(ntpUDP, "ch.pool.ntp.org", 7200, 60000);

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
#define PIN        14 // Anschluss PIN
#define NUMPIXELS 110 //Anzahl LED's

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#include <sstream>
#include <string>
#include <iostream>

void setup(){
 Serial.begin(115200);

  WiFi.begin(ssid, password);

  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );

  }
  pixels.begin();
}  

void loop(){
  const int minuten = timeClient.getMinutes();
  const int stunden = timeClient.getHours();
 
  pixels.show();
  for (int Wort = 0; Wort < Anzahlwoerter; Wort++) {
     if(*zeit_m[Wort] == minuten) {
         pixels.setPixelColor(*wort_LEDs_m[Wort], pixels.Color(150, 150, 150));
      }
  }
  for (int Wort = 0; Wort < Anzahlwoerter; Wort++) {
      if(*zeit_h[Wort] == stunden ) {
          pixels.setPixelColor(*wort_LEDs_h[Wort], pixels.Color(150, 150, 150));
      }
  }
    timeClient.update();

    Serial.print(stunden);
    Serial.print(":");
    Serial.print(minuten);
    Serial.println();
}

bei der Zeile: const int* zeit_h[]={11, 23, 5, 17, 1, 13, 2, 14, 3, 15, 4, 16, 6, 18, 8, 20, 7, 19, 12, 0, 24, 10, 22, 9, 21};

es kommt nun diese Nachricht: invalid conversion from 'int' to 'const int*' [-fpermissive]

was habe ich falsch gemacht?

Danke fürs Helfen
Selectronics 50

Klar, ein Pointer ist auch in C kein int mehr. Wieso plötzlich int* statt int?

Die Fehlermeldung sagt klar aus was du falsch gemacht hast

Spart progmem nicht mehr RAM?

DrDiettrich:
Klar, ein Pointer ist auch in C kein int mehr. Wieso plötzlich int* statt int?

weil dann bei der Zeile: const int wort_LEDs_h[]={wort_10, wort_10, wort_11, wort_11, wort_12, wort_12, wort_13, wort_13, wort_14, wort_14, wort_15, wort_15, wort_16, wort_16, wort_17, wort_17, wort_18, wort_18, wort_19, wort_19, wort_19, wort_20, wort_20, wort_21, wort_21};

diese Meldung kommt: invalid conversion from 'const int*' to 'int' [-fpermissive]

Hi

In #4 versuchst Du ja auch die ADRESSEN der ARRAYs (wort_10 und wie Sie Alle heißen) in ein Array zu setzen - Da würde ich * erwarten.

In #0 packst Du ZAHLEN in das Array - und Das sind nun Mal ZAHLEN und keine Zeiger.

MfG

Lerne bitte den Zusammenhang zwischen Arrays und Zeigern. Array Variablen sind Zeiger auf das erste Element

Hallo,

wenn ich vorgreifen darf. Du hast 2 Möglichkeiten. Ohne und mit PROGMEM.

const byte ANZAHL = 4;
const char *pText[] = {"wort_0", "wort_1", "wort_2", "wort_3"};

void setup() {
  Serial.begin(250000);

}

void loop() {

  for (byte i = 0; i < ANZAHL; i++)
  {
    Serial.println(pText[i]);
    delay(500);
  }
}

oder

// https://www.arduino.cc/reference/en/language/variables/utilities/progmem/

const char text0[] PROGMEM = "wort_0";
const char text1[] PROGMEM = "wort_1";
const char text2[] PROGMEM = "wort_2";
const char text3[] PROGMEM = "wort_3";
char buffer[10];

const byte ANZAHL = 4;
const char *const texte[ANZAHL] PROGMEM =
{
  text0,
  text1,
  text2,
  text3
};
  
void setup() {
  Serial.begin(250000);

}

void loop() {

  for (byte i = 0; i < ANZAHL; i++)
  {
    strcpy_P(buffer, (char *)pgm_read_word(&(texte[i]))); 
    Serial.println(buffer);
    delay(500);
  }
}

Doc_Arduino:
Hallo,

wenn ich vorgreifen darf. Du hast 2 Möglichkeiten. Ohne und mit PROGMEM.

const byte ANZAHL = 4;

const char *pText[] = {"wort_0", "wort_1", "wort_2", "wort_3"};

void setup() {
  Serial.begin(250000);

}

void loop() {

for (byte i = 0; i < ANZAHL; i++)
  {
    Serial.println(pText[i]);
    delay(500);
  }
}




oder 



// PROGMEM - Arduino Reference

const char text0[] PROGMEM = "wort_0";
const char text1[] PROGMEM = "wort_1";
const char text2[] PROGMEM = "wort_2";
const char text3[] PROGMEM = "wort_3";
char buffer[10];

const byte ANZAHL = 4;
const char *const texte[ANZAHL] PROGMEM =
{
  text0,
  text1,
  text2,
  text3
};
 
void setup() {
  Serial.begin(250000);

}

void loop() {

for (byte i = 0; i < ANZAHL; i++)
  {
    strcpy_P(buffer, (char *)pgm_read_word(&(texte[i])));
    Serial.println(buffer);
    delay(500);
  }
}

Hi
Dort habe ich ja kein Problem sondern bei der Zeile: const int* zeit_h[]={11, 23, 5, 17, 1, 13, 2, 14, 3, 15, 4, 16, 6, 18, 8, 20, 7, 19, 12, 0, 24, 10, 22, 9, 21};

kommt die Meldung: invalid conversion from 'int' to 'const int*' [-fpermissive]

Überlege mal, was Du in dieser Zeile speichern willst.
Ich vermute Zahlen, keine selbsausgezählten Zeiger, also int und nicht int*.

Da fehlen noch einige Grundlagen.

Gruß Tommy

Selectronics:
kommt die Meldung: invalid conversion from 'int' to 'const int*' [-fpermissive]

Wieso wurde schon gesagt. Die Fehlermeldung kann man doch auch lesen. Du hast ein Array aus Zeigern (int*) und willst diesem Werte zuweisen (int). Wieso soll das gehen?

Hi

Danke fürs helfen, jetzt kommt keine Fehlermeldung mehr. Jedoch leuchtet noch nichts. Gibt es eine Möglichkeit zum Beispiel das ich für ein array den Status true oder false bestimmen kann und dann prüfen kann welcher array true ist. Bei den arrays, welche true sind, die im array stehenden LED's leuchten lassen kann.

Es muss kein array sein habe nur einen array genommen um es möglichst verständlich zu erklären.

Danke fürs helfen
Selectronics 50

Ich weiß nicht genau, was Du meinst, aber Du kannst z.B. ein Array feldweise ausgeben lassen:

int arr[] = {1,2,3,0,5,6};
const arrLen = sizeof(arr) / sizeof(arr[0]);
...
for(byte i=0;i<arrLen;i++) {
  Serial.print(i);
  Serial.print(". ");
  Serial.println(arr[i]);
}

Gruß Tommy

Hallo,

ich glaube du hast dich gedanklich total verrannt durch den Fehler mit den Zeigern und ich hatte das falsch aufgefasst und zeige noch ein Bsp. für Textausgabe. Alles unpassend für dein Vorhaben.

Eine Wordclock besteht letztlich aus LEDs die an Pins hängen. Diese LEDs sollen leuchten. Das damit Buchstaben beleuchtet werden ist der gewollte Nebeneffekt. Das heißt außer für serielle Debugausgaben benötigst du keine Textausgabe und damit auch keine Zeiger. Du kannst alles mit Indexnummern der Arrays erschlagen. Das sind unsigned Integer Datentypen. Das heißt du musst keine Zeiger an deine Pixelklasse übergeben. So wie Tommy das zeigt. Du musst bestimmte LEDs für bestimmte Muster je nach gewünschten Text ansteuern. Das hat nichts mit Textausgabe zu tun. Ist rein digital.