-
Notifications
You must be signed in to change notification settings - Fork 9
Demo
Lucky edited this page Jan 21, 2018
·
1 revision
Arduino connected to COM5 USB, sending an int every 5 seconds
int i = 0;
String s;
unsigned long previousMillis = 0;
const long interval = 5000; // Send to serial every 5 seconds
void setup() {
Serial.begin(115200);
}
void loop() {
while (Serial.available()) {
s = Serial.readString();
Serial.print("Received from serial: ");
Serial.println(s);
}
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
Serial.print("from Arduino: ");
Serial.println(i++);
}
}
