我有一个我定义的结构的二维数组,我想在一个结构中获取一个值,该结构本身包含在一个数组中。
我曾尝试在裸 C 中执行相同类型的代码,但它似乎可以工作,而 Arudino IDE 则不能(代码不完全相同,但通常是相同的)。
请看下面的示例,我正在通过串行打印从我的结构数组中取出的任意值,并且我在串行监视器上获得的唯一输入是一套“ÿ”,从我在互联网上看到的意思是串行缓冲区为空。
您在下面的代码中是否有任何问题?(看文末看相关代码)
#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);*/
// }
// }
}
非常感谢您的帮助,我已经花了很多时间在这...