I have the following sketch...
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
if(Serial.available() > 0){
Serial.println("Hello world from Ardunio!");
}
}
This works great with my client code...
import SerialPort from 'serialport';
const port = new SerialPort('/dev/ttyACM0', {
baudRate: 115200,
autoOpen: false
})
port.open(function (err) {
if (err) {
return console.log('Error opening port: ', err.message)
}
// Because there's no callback to write, write errors will be emitted on the port:
console.log("port opened");
port.on('readable', function () {
console.log('Data:', port.read())
})
})
Now I want to slow it down so I change the sketch to...
void loop() {
if(Serial.available() > 0){
Serial.println("Hello world from Ardunio!");
}
delay(10000);
}
I would expect this to delay each message by 10 seconds, however, it seems to never rerun so I do not get any messages. What am I missing? Why would delay break the loop?
Serial.println("Hello world from Ardunio!");
?