Here, I will describe how to read the input from Serial Monitor and show the input. For this, we require Arduino IDE for writing the program. Here, I have my IDE. In case you don't have the IDE, you can download it from the following
Link.
For writing the program, go to FILE-> NEW, after which, you will get the following screen.
Afterwards, plug the Arduino board to your system.
Afterwards, write the following code to read the input from Serial Monitor and display it as follows:
- String name = "";
- String Mobile = "";
- String Address = "";
- String Email = "";
-
- void setup() {
- Serial.begin(9600);
-
- }
-
-
- void loop() {
-
- Serial.println("Enter your name.");
-
- while (Serial.available()==0)
- {
-
- }
- name=Serial.readString(); //Reading the Input string from Serial port.
-
-
- Serial.println("Enter your Moblie No.");
-
- while(Serial.available()==0)
- {
-
- }
- Mobile=Serial.readString();
-
-
- Serial.println("Enter your Address.");
- while(Serial.available()==0)
- {
-
- }
- Address=Serial.readString();
- Serial.println("Enter your Email.");
- while(Serial.available()==0)
- {
-
- }
- Email=Serial.readString();
-
- Serial.println("-------------------------"); //Showing the details
- Serial.println("YOUR NAME:"+name);
- Serial.println("YOUR MOBILE NO:"+Mobile);
- Serial.println("YOUR ADDRESS:"+Address);
- Serial.println("YOUR EMAIL:"+Email);
- Serial.println("Thanks You...");
- Serial.println("");
- while(Serial.available()==0)
- {
- }
- }
Here, I have explained which function is used. Now set the Serial port to "COM5".
Afterwards, upload the code by clicking the Upload button, using the Upload button.
Now Open the serial port and check.
Enter all the details and it will show the output like this.
Hence, in this way, we can read the input from Serial monitor and show it. I hope this will help those who are willing to learn this new technology.