Why I cannot run code NullPointerException

not understand your concept ( or question ),

  • but inside serialEvent
    • i doubt the key detection
    • also think there never should be a loop / noLoop