blob: 0886a4ac3098d3123067f4aeecda5978d2a1f698 (
plain)
- const int ledPin = 13; // LED connected to digital pin 13
- void setup() {
- pinMode(ledPin, OUTPUT);
- Serial.begin(9600);
- Serial.println("Enter 'ON' to turn the LED on, or 'OFF' to turn it off.");
- }
- void loop() {
- if (Serial.available() > 0) {
- String command = Serial.readStringUntil('\n');
- command.trim();
- if (command.equalsIgnoreCase("ON")) {
- digitalWrite(ledPin, HIGH);
- Serial.println("LED is now ON.");
- }
- else if (command.equalsIgnoreCase("OFF")) {
- digitalWrite(ledPin, LOW);
- Serial.println("LED is now OFF.");
- }
- else {
- Serial.println("Invalid command. Please type 'ON' or 'OFF'.");
- }
- }
- }
|