There are a few issues at play here. One is that the Arduino
resets every time you open the serial connection on the PC side. You can
prevent this by putting a 1 µF (or more) capacitor between 5V and
RESET. A second issue is that the tty driver may be keeping old data in
its buffer, and you get this data when you open the connection. The
third issue is that ...
A USB connection is actually very complex. And serial communications (or the CDC class of USB) is only 1 of over a dozen protocols used over USB. Most cheap embedded processors save money by leaving out this feature. Most Arduino's use cheap embedded processors. For instance, the classic Arduino Uno needs a second chip (search for New USB in this link) ...
No, you can't. The Arduino has a serial connection, not a network connection. If the Java program is of your own devising you would need to rewrite it to use serial instead of (or as well as) WebSockets. Either that or write a separate piece of software for your computer to go between the Arduino's serial connection and the WebSockets interface.
I believe the issue is that you're setting your encoder pins high with digitalWrite(). Those pins need to be configured as inputs for the interrupts to work correctly. This will be handled by the encoder library when you call r.begin(true). In fact, true in that call tells the library to enable the pullups for you.
Removing those lines should fix your ...
ok, well there are some things I don't know about your code, and hardware, like if the LCD library can handle uint64_t datatypes. I know the Serial.print() function can only handle up to a unit32_t, so I'm using that.
I think your length variable might not be the right length, you might want to add in a check for that in your code. Much of the Arduino code ...
I have noticed that many people on the net have problems using millis with the sensor to take measurements etc. so I created this sketch to help anyone.
You are free to ask for any clarification about it!
* HC-SR04 sensor measuring
* Non-blocking HC-SR04 sensor measuring
* The circuit:
* - Echo pin connected to pin 2
* - Trigger pin ...