Skip to content

How to read multiple lines #7

@PilotinControl25

Description

@PilotinControl25

Hello,

I am trying to read 2 lines sent from the arduino my code is below. I am trying to create a function when the word ABLINK is received it prints out something....same with when ABO is read. Only the first IF statement works. How can I make the second one work? I am stumped. Thanks for the help!

if(n == 39) {
    Serial.println("ABLINK");
    for(int i = 0; i < 10; i++) {
        digitalWrite(13, HIGH);
        delay(1000);
        digitalWrite(13, LOW);
        delay(150);
    }
    delay(1000);
    Serial.println("ABO");
}

And my Java code is below:

String line = arduino.serialRead('6');
if(line.contains("ABLINK")) {
    System.out.println("ALL LEDS BLINKING");
} else {
    AnsiConsole.systemInstall();
    System.out.println("ERROR!!");
} 
String line2 = arduino.serialRead('4');
if(line2.contains("ABO")) {
    System.out.println("ALL LEDS BLINKING OFF");
} else {
    System.out.println("ERROR!! line="+ line +"<");
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions