// רובוטרוניקס לימוד ארדואינו , לימוד רובוטיקה
// http://www.robotronix.co.il
const int ledPin = 2; // Pin connected to the LED
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW); // Turn off the LED initially
}
void loop() {
if (Serial.available() > 0) {
String command = Serial.readStringUntil('\n');
command.trim(); // Remove leading and trailing whitespaces
// Process the received command
if (command == "on") {
digitalWrite(ledPin, HIGH); // Turn on the LED
Serial.println("LED is ON");
} else if (command == "off") {
digitalWrite(ledPin, LOW); // Turn off the LED
Serial.println("LED is OFF");
} else {
Serial.println("Invalid command. Available commands: 'on' and 'off'");
}
}
}