char input; // Declare the input variable to store the serial input
void setup() {
pinMode(12, OUTPUT); // Set pin 12 as an output pin
Serial.begin(9600); // Start serial communication at 9600 baud rate
Serial.println("Arduino control of LED Using serial Monitor"); // Print a message to the serial monitor
}
void loop() {
if (Serial.available()) { // Check if there is any data available to read
input = Serial.read(); // Read the data and store it in the input variable
}
if (input == '1') { // If the input is '1'
digitalWrite(12, HIGH); // Turn the LED on (pin 12 HIGH)
}
if (input == '0') { // If the input is '0'
digitalWrite(12, LOW); // Turn the LED off (pin 12 LOW)
}
}