0% found this document useful (0 votes)
5 views1 page

Control Arduino LED via Serial Monitor

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Control Arduino LED via Serial Monitor

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Serial Control of LED on Arduino Pin 13

Description:
This program allows the user to control the LED connected to pin 13 of the Arduino using
the serial monitor. When the program starts, the LED is off. Sending '1' via the serial
monitor turns the LED on, and sending '0' turns it off. This can be tested using a physical
Arduino or the Tinkercad Arduino simulator.

C Program:
// Project: Serial Control of LED on Pin 13
// Author: NITHYA SRI D
// Description: The user can control the LED via the serial monitor.
// Send '1' to turn the LED on and '0' to turn the LED off.

const int ledPin = 13; // Pin connected to the LED


char inputChar; // Variable to store serial input

void setup() {
pinMode(ledPin, OUTPUT); // Set pin 13 as output
digitalWrite(ledPin, LOW); // Start with LED off
[Link](9600); // Initialize serial communication at 9600 baud
}

void loop() {
if ([Link]() > 0) { // Check if data is available
inputChar = [Link](); // Read one character

if (inputChar == '1') {
digitalWrite(ledPin, HIGH); // Turn LED on
}
else if (inputChar == '0') {
digitalWrite(ledPin, LOW); // Turn LED off
}
}
}

You might also like