Probleme d'accès à un tableau

Bonjour,

Ton tableau semble être un tableau à deux dimensions. Si c'est le cas, il faut le définir comme tel

const byte tab[][8] =
{
  {1, 1, 1, 1, 1, 1, 0, 0},
  {0, 1, 1, 0, 0, 0, 0, 0},
  {1, 1, 0, 1, 1, 0, 1, 0},
  {1, 1, 1, 1, 0, 0, 1, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {1, 0, 1, 1, 0, 1, 1, 0},
  {1, 0, 1, 1, 1, 1, 1, 0},
  {1, 1, 1, 0, 0, 1, 0, 0},
  {1, 1, 1, 1, 1, 1, 1, 0},
  {1, 1, 1, 1, 0, 1, 1, 0},
  {0, 0, 0, 0, 0, 0, 0, 1}
};

Pour l'afficher:

const byte tab[][8] =
{
  {1, 1, 1, 1, 1, 1, 0, 0},
  {0, 1, 1, 0, 0, 0, 0, 0},
  {1, 1, 0, 1, 1, 0, 1, 0},
  {1, 1, 1, 1, 0, 0, 1, 0},
  {0, 1, 1, 0, 0, 1, 1, 0},
  {1, 0, 1, 1, 0, 1, 1, 0},
  {1, 0, 1, 1, 1, 1, 1, 0},
  {1, 1, 1, 0, 0, 1, 0, 0},
  {1, 1, 1, 1, 1, 1, 1, 0},
  {1, 1, 1, 1, 0, 1, 1, 0},
  {0, 0, 0, 0, 0, 0, 0, 1}
};
const byte NB_LIGNES=sizeof tab/sizeof tab[0];

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

  for (byte ligne=0; ligne<NB_LIGNES; ligne++)
  {
    for (byte col=0; col<8; col++)
    {
      Serial.print(tab[ligne][col]);
      Serial.print(" ");
    }
    Serial.println();
  }
}

void loop()
{
}
1 Like