pcbway




arduino serial write, serial write arduino, arduino write serialHello everyone, I hope you all are fine and having fun with your lives. Today, I am going to share the next tutorial in this series of basic Arduino tutorials and its named as How to use Arduino Serial Write. In this tutorial, I have given an overview of How to use the Arduino Serial Write Command. In the previous tutorial, we have seen How to use Arduino Serial Read ? in which we have read the data coming from the serial port.

While today we will have a look at how to send the data through serial port in arduino and for that I am gonna use the Arduino Serial Write command. Its also gonnabe a very simple and basic Arduino tutorial but if you are new to Arduino then you must read it completely as it will gonna help you out. I have also designed a Proteus Simulation and explained it at the end of this tutorial. I hope you guys are gonna learn from it:

How to use Arduino Serial Write ???

arduino serial write, serial write arduino, arduino write serial

  • In the Arduino Serial Read, we have seen that How to read data coming from serial port and we have used Pin # 0 for that purpose.
  • So, now we are gonna write some data on the Serial Port.
  • It’s like we are sending data from Arduino to some other device via Serial Port.
  • For example, you are using GSM module with Arduino then you have to send AT commands to your GSM baord from Arduino and that’s where you use Arduino Serial write.
  • You can download the Proteus Simulation and code for Arduino Serial Write Command by clicking the below button:

Download Simulation and Code

  • Here’s the first syntax for Arduino Serial write:

Arduino Serial Write Syntax 1:

  • Arduino Serial Write is used to write some data on the Serial Port adn it send data in binary form.
  • Here’s Arduino Serial Write Syntax:

Serial.write ( ‘DataSent’ ) ;

where:

  • DataSent is a simple byte and is used in these characters ‘ ‘. The below example code will send the byte 1 on the serial port:

Serial.write ( ‘1’ ) ;

  • Now, let’s write some data on Arduino Serial Port using the above syntax and see what we got.
  • So, design a Proteus Simulation as shown in below figure:

arduino serial write, serial write arduino, arduino write serial

  • In the above code, I have simply written a byte which you can see is 1.
  • So, now upload it and run your simulation and if everything goes fine then you will get 1 on your virtual serial terminal of Proteus, as shown in below figure:

arduino serial write, serial write arduino, arduino write serial

  • You can see in the above figure that we got 1 in Serial Port so now you can send whatever you want via this Arduino Serial Write Command.
  • Now let’s have a look at the second syntax of Arduino Serial Write command:

Arduino Serial Write Syntax 2:

  • We can also send a String of byte via Arduino Serial Write Command. Here’s the syntax:

Serial.write ( “DataSent” ) ;

where:

  • DataSent is a simple byte and is used in these characters ” “. The below example code will send the our site address on the serial port:

Serial.write ( “www.TheEngineeringProjects.com” ) ;

  • Now let’s sent a string of byte through this Arduino Serial Write Command, so I have used the below code and have sent our website address via Serial Write.
  • So, use the below code and get your Hex File:

  • Run your Proteus Simulation and you will get the below results:

arduino serial write, serial write arduino, arduino write serial

  • You can see in the above figure that we got the whole address via Serial Port.

That’s all for today, I hope you guys have enjoyed today’s post. In the coming post, I am gonna discuss the Arduino Print Command. Thanks for reading. Take care.

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment