/* Created by ArduinoGetStarted.com This example code is in the public domain Tutorial page: https://arduinogetstarted.com/tutorials/ar duino-servo-motor-controlled-by-potentiometer */ int mode1 = 0; int mod2 = 0; int mod3 = 0; void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); } void loop() { // check if data has been sent from the computer: while (Serial.available() > 0) { // read the most recent byte (which will be from 0 to 255): //angle01 = Serial.read(); int a = Serial.parseInt(); int b = Serial.parseInt(); int c = Serial.parseInt(); if (Serial.read() == '\n') { mode1 = a; mode2 = b; mode3 = c; } } if (mode1 == 0) { digitalWrite(LED_BUILTIN, LOW); } else if (mode1 == 1) { digitalWrite(LED_BUILTIN, HIGH); } else { ///.... } delay(100); }