I have a bidimensional array of struct that I defined and I want to get a value in a struct which itself is contained in an array.
I have tried to do the same kind of code in bare C and it seems to work while or Arudino IDE it doesn't (code isn't the exact same but it's generally the same thing).
Look at the example below, I am printing an arbitrary value taken out of my array of struct over serial and the only input I get on the Serial Monitor is a suit of 'ÿ' which from what I've seen on the internet means that the serial buffer is empty.
Does anything look wrong to you within the code below? (look at the end to see the relevant code)
/*
* Metro - Station finder
* Copyright © 2013, Adrien Tétar. All Rights Reserved.
*/
#include <Wire.h>
typedef struct {
char nom[17]; // wanted number +1 for terminaison
byte cor1[2]; // correspondance
byte cor2[2];
byte cor3[2];
byte cor4[2];
byte i2c;
byte led;
} Station;
Station lignes[14][15] = {{
{"Champs Elysees", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11101111},
{"Concorde", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B10111111},
{"Tuileries", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B11101111},
{"Palais Royal", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B10111111},
{"Louvre Rivoli", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100010, B11101111},
{"Chatelet", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B10111111},
{"Hotel de Ville", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B11101111},
{"St-Paul", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11011111},
{"Bastille", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11110111},
{"Ledru-Rollin", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11110111},
{"Faidherbe", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111011}
},
{
},
{
{"Saint-Lazare", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11111110},
{"Havre Caumartin", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B11111110},
{"Opera", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100010, B11110111},
{"Quatre Septembre", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100010, B11111101},
{"Bourse", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B11011111},
{"Sentier", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B11110111},
{"R. Sebastopol", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B11111101},
{"Arts et Metiers", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B01111111},
{"Temple", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B10111111},
{"Republique", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11110111}
},
{
{"S. Saint-Denis", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11011111},
{"R. Sebastopol", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B11111101},
{"Etienne Marcel", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B11111011},
{"Les Halles", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100010, B10111111},
{"Chatelet", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B10111111},
{"Cite", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B01111111},
{"St-Michel", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111110},
{"Odeon", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111101},
{"St-Germain", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100101, B10111111},
{"Saint-Sulpice", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B10111111},
{"St-Placide", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B01111111},
{"Montparnasse", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11101111},
{"Vavin", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B01111111},
{"Raspail", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111011},
{"Denfert", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11101111}
},
{
{"J. Bonsergent", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11111011},
{"Republique", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11110111},
{"Oberkampf", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B01111111},
{"Richard Lenoir", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111110},
{"Breguet Sabin", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111101},
{"Bastille", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11110111},
{"Quai de la Rapee", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111101},
{"Gare Austerlitz", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11101111},
{"Saint Marcel", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B10111111},
{"Campo Formio", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11011111},
},
{
{"Pasteur", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11011111},
{"Montparnasse", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11101111},
{"Edgar Quinet", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B10111111},
{"Raspail", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111011},
{"Denfert", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11101111}
},
{
{"Le Peletier", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B11110111},
{"La Fayette", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B11111011},
{"Opera", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100010, B11110111},
{"Pyramides", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B01111111},
{"Palais Royal", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B10111111},
{"Pont Neuf", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100010, B11011111},
{"Chatelet", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B10111111},
{"Pont Marie", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111101},
{"Sully Morland", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111110},
{"Jussieu", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111011},
{"Place Monge", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11110111},
{"C. Daubenton", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111011},
{"Les Gobelins", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B10111111},
},
{
{"Invalides", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100101, B11110111},
{"Concorde", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B10111111},
{"Madeleine", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11011111},
{"Opera", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100010, B11110111},
{"Richelieu Drouot", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B11111101},
{"Gds Boulevards", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100010, B11111011},
{"Bonne Nouvelle", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B11111110},
{"S. Saint-Denis", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11011111},
{"Republique", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11110111},
{"F. du Calvaire", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11101111},
{"St-S. Froissart", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100010, B01111111},
{"Chemin Vert", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B01111111},
{"Bastille", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11110111},
{"Ledru Rollin", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11110111},
{"Faidherbe", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111011}
},
{
{"Saint Philippe", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11110111},
{"Miromesnil", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11111011},
{"Saint-Augustin", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11111101},
{"Havre Caumartin", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B11111110},
{"La Fayette", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B11111011},
{"Richelieu Drouot", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100110, B11111101},
{"Gds Boulevards", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100010, B11111011},
{"Bonne Nouvelle", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B11111110},
{"S. Saint-Denis", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11011111},
{"Republique", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11110111},
{"Oberkampf", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B01111111}
},
{
{"Duroc", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11110111},
{"Vanneau", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B01111111},
{"Sevres Babylone", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111011},
{"Mabillon", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100101, B01111111},
{"Odeon", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111101},
{"La Sorbonne", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111101},
{"Maubert", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11011111},
{"Cardinal Lemoine", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B01111111},
{"Jussieu", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111011},
{"Gare Austerlitz", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11101111}
},
{
{"Chatelet", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B10111111},
{"Hotel de Ville", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B11101111},
{"Rambuteau", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B11011111},
{"Arts et Metiers", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B01111111},
{"Republique", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11110111},
{"Goncourt", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11111101},
{"Belleville", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100000, B11111110}
},
{
{"Saint-Lazare", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11111110},
{"Madeleine", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11011111},
{"Concorde", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B10111111},
{"Assemblee", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100101, B11111011},
{"Solferino", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100101, B11111110},
{"Rue du Bac", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100101, B11101111},
{"Sevres Babylone", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111011},
{"Rennes", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11101111},
{"N-D. Des-Champs", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11011111},
{"Montparnasse", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11101111},
{"Falguiere", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B10111111},
{"Pasteur", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11011111},
{"Volontaires", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11101111}
},
{
{"Saint-Lazare", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11111110},
{"Miromesnil", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11111011},
{"Champs Elysees", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11101111},
{"Invalides", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100101, B11110111},
{"Varenne", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100101, B11111101},
{"St-Fr. Xavier", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100101, B11011111},
{"Duroc", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11110111},
{"Montparnasse", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11101111},
{"Gaite", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11111110}
},
{
{"Saint-Lazare", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11111110},
{"Madeleine", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B11011111},
{"Pyramides", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100001, B01111111},
{"Chatelet", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0100100, B10111111},
{"Gare de Lyon", {0, 0}, {0, 0}, {0, 0}, {0, 0}, B0111000, B11110111}
}};
void setup() {
// Wire.begin();
Serial.begin(9600);
}
void loop(){
// for (int j=0; j<16; j++) {
byte a = lignes[0][0].i2c;
Serial.write(a);
/* for (int i=0; i<14; i++) {
Serial.print(lignes[0][i].i2c, BIN);
Serial.print(lignes[0][i].led, BIN);
Serial.println(" ");
/* Wire.beginTransmission(lignes[0][i].i2c); // PCF8574P GGG
Wire.write(lignes[0][i].led);
Wire.endTransmission();
delay(10);*/
// }
// }
}
Thanks a lot in advance for your help, I already spent a lot of time on this...
char nom[17]
field to aconst char *nom
. – unwind May 13 '13 at 14:34