Hiiiilfeeeee

ich habe hier den folgenden programmcode gefunden :

void loop() {
while (gpsSerial.available()) {
hauptZeile[hschlecht] = gpsSerial.read();
if (hauptZeile[hschlecht++] == '\n') {
hauptZeile[hschlecht-1] = '\0'; // Ende einer Zeile -> Ende des Strings
if (hauptZeile[0] == '$' && hauptZeile[1] == 'G' && hauptZeile[2] == 'P' && hauptZeile[3] == 'R' && hauptZeile[4] == 'M' && hauptZeile[5] == 'C') {
Serial.println(hauptZeile);// GPRMC..

und ich bin neu im gebiet programmieren ^^
da wollte ich mal wissen was genau die bedingung der zeile:

if (hauptZeile[hschlecht++] == '\n') {

bedeutet... kann mal nix mit dem '\n' anfangen
danke schonmal für die hilfe :)))

if (hauptZeile[hschlecht++] == '\n') {

Da wird die das Arrayelement "hauptZeile[hschlecht]" verglichen ob es das Zeichen "\n" (return oder 13 oder 0X0A) ist und sofort nach dem vergleich der index "hschlecht" um 1 erhöht.
Grüße Uwe

hello :slight_smile: i've this code :

void loop() {
while (gpsSerial.available()) {
hauptZeile[hschlecht] = gpsSerial.read();
if (hauptZeile[hschlecht++] == '\n') {
hauptZeile[hschlecht-1] = '\0'; // Ende einer Zeile -> Ende des Strings
if (hauptZeile[0] == '$' && hauptZeile[1] == 'G' && hauptZeile[2] == 'P' && hauptZeile[3] == 'R' && hauptZeile[4] == 'M' && hauptZeile[5] == 'C') {
Serial.println(hauptZeile);// GPRMC..

and i'm new in programming ^^
and i dont know what this means:

if (hauptZeile[hschlecht++] == '\n') {

another example:

if(string[i++]=='\n'

i dont know what the '\n' makes
could someone explain to me ??
thx 4 help

\n is the way C represents the linefeed (LF) character. It is Ascii character 10

daaaanke für die schnelle antwort :slight_smile:

Hello,
hauptZeile[] is an array of character and the code

if (hauptZeile[hschlecht++] == '\n')

simply checks if the character at index hschlecht is equal to the constant '\n' that is a newline. A character constant is specified between single quotation marks es. 'A', '2', 'b', etc. Special characters are indicated by using the escape sequence: '\n' is a new-line, '\t' is a tab, etc.
It seems that your code is reading characters from the serial port and detects the end of a sentence by checking the new-line character.

thanks for the fast reply :slight_smile:

helps much :slight_smile:

hat mir sehr geholfen :slight_smile:

What is the German for "DO NOT CROSS-POST", please?

Ben1306
Es ist schlechtes Benehmen (Netikette) in einem Forum die gleiche Frage in verschiedenen Kategorien zu stellen.
Grüße Uwe Federer

Danke

Das tut mir leid kommt nicht mehr vor :wink: ist mein erstes forum in dem ich angemeldet bin ^^

Ben1306:
Das tut mir leid kommt nicht mehr vor :wink: ist mein erstes forum in dem ich angemeldet bin ^^

Dann gebe ich dir noch einen weiteren Tipp auf den Weg: Wähle als Titel etwas aussagekräftigeres als "Hiiiilfeeee". Man soll hieran ja erkennen, worum es geht.