Hallo , ich betreibe vier LCD's an einem Arduino mit folgendem Code , das funktioniert soweit ganz gut.
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd1(12, 8, 5, 4, 3, 2);
LiquidCrystal lcd2(12, 9, 5, 4, 3, 2);
LiquidCrystal lcd3(12, 10, 5, 4, 3, 2);
LiquidCrystal lcd4(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of rows and columns:
lcd1.begin(16, 2);
lcd2.begin(16, 2);
lcd3.begin(16, 2);
lcd4.begin(16, 2);
// Print a message to the LCD.
lcd1.setCursor(0, 1);
lcd1.print("1");
lcd2.setCursor(0, 1);
lcd2.print("2");
lcd3.setCursor(0, 1);
lcd3.print("3");
lcd4.setCursor(0, 1);
lcd4.print("4");
}
void loop() {
}
um aber den Code möglichst klein zuhalten , ist meine Frage , ob man die LCD's-Bezeichnung in einem Array packen kann ? So stelle ich mir den Code dann vor:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
for (int i=1; i <= 4; i++){
LiquidCrystal lcd*(12,7+i, 5, 4, 3, 2);*
}
void setup() {
// set up the LCD's number of rows and columns:
for (int i=1; i <= 4; i++){
lcd*.begin(16, 2);*
}
// Print a message to the LCD.
for (int i=1; i <= 4; i++){
lcd*.setCursor(0, 1);*
lcd*.print(i);*
}
void loop() {
}
Ich hoffe , mit meiner laienhaften Erklärung kommt einer klar und hat eine Lösung für mich !
Gruß