const int startup_charsPerLine = 80;
definiert die Anzahl Zeichen je Zeile auf 80
const int startup_num_lines = 2;
Anzahl der Zeilen der Startnachricht
byte startup_message[startup_num_lines][startup_charsPerLine] = {
"startup_message = Name der Variable für den Druck // {=Beginn der Nachricht?
"This is the startup message. It prints whenever",
Zeile 1 Startnachricht
"the Arduino is reset.",
Zeile 2 Startnachricht
};
} Ende der Nachricht?
const int charsPerLine = 80; // this is the max # of chars per line
maximal 80 Zeichen je Zeile wie oben
const int num_lines = 10;
Anzahl Zeilen für Pin A0 auf GND Druckausgabe
byte message[num_lines][charsPerLine] = {
"message" ist der Name der Variable die später für den Druck aufgerufen wird?
" ", // blank line
"This is the normal message. It prints whenever",
"you connect pin 14 (analog 0) to GND.",
" ", // blank line
"------------------------------------------------------------------------------", // a spiffy line
"1) More message content",
" ",
"II) you can have up to about 80 chars per line ",
" ",
"------------------------------------------------------------------------------",
};
// parallel port pin# = arduino pin#
const int nStrobe = 2;
const int data_0 = 3;
const int data_1 = 4;
const int data_2 = 5;
const int data_3 = 6;
const int data_4 = 7;
const int data_5 = 8;
const int data_6 = 9;
const int data_7 = 10;
const int nAck = 11;
const int busy = 12;
const int strobeWait = 2; // microseconds to strobe for
void setup() {
Serial.begin(9600);
pinMode(nStrobe, OUTPUT); // is active LOW
digitalWrite(nStrobe, HIGH); // set HIGH
pinMode(data_0, OUTPUT);
pinMode(data_1, OUTPUT);
pinMode(data_2, OUTPUT);
pinMode(data_3, OUTPUT);
pinMode(data_4, OUTPUT);
pinMode(data_5, OUTPUT);
pinMode(data_6, OUTPUT);
pinMode(data_7, OUTPUT);
pinMode(nAck, INPUT); // is active LOW
pinMode(busy, INPUT);
pinMode(13, OUTPUT);
pinMode(14, INPUT); // analog pin 0 on duemilanove and uno
digitalWrite(14, HIGH); // enable pull-up
delay(1000);
resetPrinter();
printStartupMessage();
Aufruf Druckbefehl für Startdruck
resetPrinter();
Serial.println("Delay for 5 sec");
Ausgabe Serielle Schnittstelle Log?
delay(5000);
Wartezeit 5 Sekunden, bis der nächste Resetbefehl kommen darf?
Serial.println("Startup complete");
Ausgabe Serielle Schnittstelle Log?
}
void loop() {
while(digitalRead(14) == HIGH) {
// wait
}
resetPrinter();
printMessage();
resetPrinter();
}
void printByte(byte inByte) {
while(digitalRead(busy) == HIGH) {
// wait for busy to go low
}
int b0 = bitRead(inByte, 0);
int b1 = bitRead(inByte, 1);
int b2 = bitRead(inByte, 2);
int b3 = bitRead(inByte, 3);
int b4 = bitRead(inByte, 4);
int b5 = bitRead(inByte, 5);
int b6 = bitRead(inByte, 6);
int b7 = bitRead(inByte, 7);
digitalWrite(data_0, b0); // set data bit pins
digitalWrite(data_1, b1);
digitalWrite(data_2, b2);
digitalWrite(data_3, b3);
digitalWrite(data_4, b4);
digitalWrite(data_5, b5);
digitalWrite(data_6, b6);
digitalWrite(data_7, b7);
digitalWrite(nStrobe, LOW); // strobe nStrobe to input data bits
delayMicroseconds(strobeWait);
digitalWrite(nStrobe, HIGH);
while(digitalRead(busy) == HIGH) {
// wait for busy line to go low
}
}
void resetPrinter() {
Serial.println("Reseting printer...");
Ausgabe Serielle Schnittstelle Log?
printByte(27); // reset printer
27= setzt den Drucker tatsächlich zurück?
printByte('E');
?
Serial.println("Printer Reset");
Ausgabe Serielle Schnittstelle Log?
}
void printMessage() {
digitalWrite(13, HIGH);
for(int line = 0; line < num_lines; line++) {
legt die Zeile 1 als Zeile 0 fest und gibt die Addition der nächsten Zeilen vor?
for(int cursorPosition = 0; cursorPosition < charsPerLine; cursorPosition++) {
byte character = message[line][cursorPosition];
Variable "message" wird aufgerufen
printByte(character);
delay(1);
}
printByte(10); // new line
?
printByte(13); // carriage return
?
}
digitalWrite(13,LOW);
}
void printStartupMessage() {
Serial.println("Print start-up mssage");
Ausgabe der Seriellen Schnittstelle, als Log?
digitalWrite(13, HIGH);
for(int line = 0; line < startup_num_lines; line++) {
for(int cursorPosition = 0; cursorPosition < startup_charsPerLine; cursorPosition++) {
was bedeutet das cursorPosition?
byte character = startup_message[line][cursorPosition];
Variable "startup_message" wird aufgerufen
printByte(character);
// delay(1);
}
printByte(10); // new line
printByte(13); // carriage return
Serial.print("Line ");
Ausgabe Serielle Schnittstelle Log, Line ist der Text der ausgegeben wird
Serial.print(line);
Ausgabe Serielle Schnittstelle Log, "line" die Zahl der Zeile?
Serial.println(" printed.");
Ausgabe Serielle Schnittstelle Log?
}
Serial.println("Startup message printed");
Ausgabe Serielle Schnittstelle Log?
digitalWrite(13,LOW);
}
------------------------------------------------------------------------------------
Ich habe mal versucht den Code/Sketch zu kommentieren, mit dem was ich zum Teil meine wofür das gut sein soll.
@andreas6:
Ich bin dafür glaub echt zu doof, bzw. einfach noch zu weit weg von dem ganzen Thema,
ich habe das vorhin einfach mal versucht. Das einzige was ich hinbekommen habe war,
dass vor meinem Text eine Zahl/Buchstabe vorne angestellt wurde.
Kannst du mir sagen wo ich das einfügen müsste und wie es genau aussehen müsste?
Jetzt geht´s erstmal mit dem Sohnemann spazieren, so kann man nicht arbeiten mit einem schreiendem Baby
Gruß Pascal