How to use Arduino Serial Flush?
Hello friends, I hope you all are fine and having fun with your lives. Today, I am going to share a very quick and basic tutorial in which I will show you How to use Arduino Serial Flush. I hope you guys are going to like it. We have seen How to use Arduino Serial Write? In that tutorial, we have sent some data over the Serial Port so you must recall that tutorial because we are going to use the same example today. Moreover, it's also good if you have a look at How to use Arduino Serial Monitor because that's also related.
Moreover, I hope that's going to be my last lecture on Arduino Serial Port because I have covered it in full detail. Although I am going to summarize all the Arduino Serial Post Commands in a single Post. You should also have a look at How to do Arduino Serial communication because, in that tutorial, I have combined all Arduino Serial Projects. Anyways, let's get started with How to use Arduino Serial Flush:
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | Arduino Uno | Amazon | Buy Now |
How to use Arduino Serial Flush?
- Arduino Serial Flush is used to flush the data sent through Arduino Serial Port.
- When we send data on a serial port through Arduino then we use the command Serial.print() or Serial. write().
- So when the data is sent it is sent using interrupt and when we use Arduino Serial Flush command then it makes sure that all the data is sent through serial port and nothing's left in the stream.
- In simple words, it clears the serial data stream and kind of refreshes it and also makes you ready to send the next data.
- Here's the syntax to use the Arduino Serial Flush command:
Serial.flush();
- It doesn't return anything that's why we haven't assigned any variable to it.
- It's just a simple function that clears the data on the transmitting pin of Arduino.
- Now, if you want to remove that on receiving pin of Arduino, then you just need to write this command:
while(Serial.available());
- But you make sure while using the above command because if you are receiving the data continuously then your code will remain stuck and won't move forward unless you got the complete data.
- So, here's the small code which I have also used in the Arduino Serial Write tutorial but now I am using the Arduino Serial Flush command too.
- So, here's the code:
#include
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(20, 4);
// Print a message to the LCD.
lcd.setCursor(1,0);
lcd.print("www.TheEngineering");
lcd.setCursor(4,1);
lcd.print("Projects.com");
lcd.setCursor(1,0);
Serial.begin(9600);
// lcd.clear();
Serial.write("www.TheEngineeringProjects.com");
Serial.flush();
}
void loop()
{
}
- In the above code, I have simply added the Arduino Serial Flush code and now it will take a little more time to complete because now it will make sure that all the data has been sent.
So, that's all for today. I hope you guys have enjoyed this short Arduino Serial Flush tutorial. If you have any questions, please ask in the comments. Take care !!! :)
How to use Arduino Serial Monitor ?
Hello friends, I hope you all are fine and having fun with your lives. In today's tutorial, I am going to show you
How to use Arduino Serial Monitor. It's not gonna be a very big post but its really very essential if you wanna learn Arduino coding. Because Arduino Serial Monitor is a great debugging tool and it helps a lot in Arduino Projects. In the previous post we have seen
How to use digitalRead in Arduino and if you recall that tutorial then you must remember that in it we have used some Serial printing. So that's what we are gonna cover in today's tutorial.
Before going into the details, I must suggest you to first read these two posts because in those tutorials I have shown the serial communication which is essential for Serial Monitor Working. So, you guys must first read them and then continue this tutorial. IF you have any questions then ask in the comments.
So, now let's get started with Introduction of
Arduino Serial Monitor:
How to open Arduino Serial Monitor ?
- There are two ways to open Arduino Serial Monitor, so let's discuss both of them one by one:
First way
- Open your Arduino Software and then click on the small box in the right top corner as shown in the below figure:
- Your Arduino must be connected to your computer when you click this Serial Monitor.
- If Arduino is not connected then it will create error but if Arduino is connected and configured then it will open a new window as shown in below figure:
- This new window is called Arduino Serial Monitor, we are gonna discuss how to use it in the next section, let's have a look at the second way of opening it:
Second Way
- You can also open it by clicking on the Tools in the Top Menu and then click Serial Monitor and same Serial Monitor will open up as shown in below figure:
- You can also use the short keys Ctrl+Shift+M to open Arduino Serial Monitor.
- So, that's all about How to open Arduino Serial Monitor. So, now let's have a look at How to use it and why to use it ? :)
What is Arduino Serial Monitor ?
- Arduino Serial Monitor is a simple tool available in Arduino software.
- Arduino Serial Monitor is used in Serial communication and it prints data, whatever you send through the serial port of Arduino will also be view able on this Serial Monitor.
- In Windows XP, we have a Hyper Terminal which is used for Serial communication and this Arduino Serial Monitor is just a replica of that Hyper Terminal.
- So, using this Arduino Serial Monitor you can check what you are sending and you can also place checks in your code.
- For example, I want to check the status f any digital Pin then I can simply Serial print it that when some button is pressed then I will be notified.
- I am gonna discuss it in detail further. but first let's have a simple data sending on Serial Monitor.
- So, connect your Arduino and then upload the below code in it:
void setup() {
Serial.begin(9600);
Serial.print("www.TheEngineeringProjects.com");
}
void loop() {
// put your main code here, to run repeatedly:
}
- Now you can see in the above code that I just begin my serial port and then I have used the command Serial.print to print some data on the Serial Port.
- So, now upload this code in your Arduino board which must be connected to your computer in order to work this Serial Monitor.
- After uploading the code, now open your Serial Monitor and you will get this data in your Serial Monitor which means this data has been sent Serially as shown in below figure:
- Now you can see that our data has been sent serially.
Note:
- Serial Monitor is using the Serial Port so that's why its directly connected to Pin # 0 and Pin # 1 of Arduino.
- When you open your Serial Monitor then your Arduino resets.
- You can change the baud rate from lower right corner so because we have begin our Serial port with baud rate 9600 that's why I have selected 9600 in Serial Monitor.
- Now if you manually want to send some data on the Serial Port of your Arduino (RX) then you can type in above bar and then click Send.
- So, let's design a small code in which we will send the data on the Serial Port which will be received on it.
- So, upload the below code in your Arduino and open your Serial Monitor.
void setup()
{
Serial.begin(9600);
Serial.println("www.TheEngineeringProjects.com");
}
void loop()
{
if(Serial.available())
{
char data = Serial.read();
Serial.print(data);
}
}
- Now, open your Serial Monitor and type something in it and it will be printed on your Serial Monitor as shown in below figure:
- So, I have printed my name and then Send it and it is printed on the Serial Monitor.
- Now, you know both ways of How to use Arduino Serial Monitor, now let me tell you where you can use it.
Serial Monitor as a Debugging Tool
- Serial Monitor is a great debugging tool.
- You can place checks in your code like you wanna see how many lines are working.
- So, if your code is of like 500 lines then you can place check in between like after 100 lines to see if its working or not.
- Similarly, if you are dealing with some GPS module then you can receive its data via the Software Serial and then can print it on the Serial Monitor to see that you are getting the data correctly.
- For having a look at Serial Data Receive you should check Send SMS using Sim900 and Arduino because in that post I have sent data over Serial Port and received data and then printed it on Serial Monitor.
- Here's an awesome video in which one of our team members has shown how to use Arduino Serial Monitor:
So, that's all about the Arduino Serial Monitor and I hope you guys have enjoyed it. I am gonna share more Arduino basic tutorials soon. Take care !!! :)
How to use digitalRead in Arduino ?
Hello everyone, I hope you all are fine and having fun. Today's tutorial is the next episode in the series of basic
Arduino tutorial for Beginners. In today's tutorial, we are gonna have a look at
How to use digitalRead in Arduino. In the previous tutorial, we have seen
How to use pinMode Arduino Command, which sets the Arduino Pin either as Input or Output. So, if you are using this pin as input then you have to read its status and that's where you need to use this digitalRead Arduino Command.
Other than Serial Pins in Arduino UNO, we also have 12 digital Pins. Serial Pins are also digital Pins so in total we have 14 digital Pins in Arduino UNO starting from 0 to 13. I am gonna explain them in detail in today's tutorial and we will also have a look at How to use this
digitalRead command in Arduino. So, let's get started with it:
How to use digitalRead in Arduino ?
- As I have explained in the above section that Arduino UNO has 14 digital pins in total starting from 0 to 13 as shown in below figure:
- So, you can see in the above figure that we have RXD at 0 which is sued for Serial receiving and then we have TXD at 1 used for Serial writing.
- So, these pins from 0 to 13 are all digital and after these digital Pins we have GND.
- Now I hope you have got the idea of digital Pins.
- Next thing is How to use these digital Pins, normally we connect different digital sensors with these digital Pins.
- For example, I have a digital Sensor named as Vibration Sensor. This sensor gives HIGH when it feels vibrations and gives LOW in normal condition.
- So, I am gonna connect the Signal Pin of this Sensor with any digital Pin of Arduino.
- Now, coming towards digitalRead command, this digitalRead command is used in Arduino for reading the status of digital Pins on Arduino.
- So, when we want to read whether the digital Pin of Arduino is HIGH or LOW, we use this digitalRead command.
- The syntax of digitalRead is as follows:
int Reading = digitalRead (int PinNumber);
- digitalRead command takes one input which is the value of the Pin, like if you wanna read the digital status of Pin # 8 then you have to enter 8 in the small brackets of digitalRead.
- digital Read returns Boolean data which is either HIGH or LOW and it is saved in the integer variable which I have named Reading in the above syntax. We have discussed it in Arduino Datatypes.
- So, let's have a look at the example of digitalRead:
Reading = digitalRead (8);
- In the above example, I am reading the status of digital Pin # 8 of Arduino and saving it value in the Reading variable.
- So, I hope now you have understood completely How to use the digital Read in Arduino.
Note:
- One important thing to note here is that because we are reading the data from digital Pin so that digital Pin must have to be an input.
- So, you need to declare that Pin as an input.
- So, let's have a look at a small code in which we will read the status of pin # 8 of Arduino and then display its status on Serial Monitor.
- I hope you have already read How to write Arduino Code and knows its basics.
int Pin = 8; // Initializing Arduino Pin
int Reading;
void setup() {
pinMode(Pin, INPUT); // Declaring Arduino Pin as an Input
}
void loop() {
Reading = digitalRead(Pin); // Reading status of Arduino digital Pin
if(Reading == HIGH)
{
Serial.println("HIGH");
}
if(Reading == LOW)
{
Serial.println("LOW");
}
}
Summary
So, here's a short summary of the above discussion for a quick revision:
Definition:
- digitalRead is used to read the status of any digital Pin in Arduino.
- We have to give the digital Pin number in the small brackets.
Syntax:
- Syntax of digital Read is:
int Reading = digitalRead (int PinNumber);
Return:
- digitalRead returns HIGH or LOW depending on the status of corresponding digital Pin.
Example:
Reading = digitalRead (8);
Restriction:
- Before reading status of any digital Pin, we have to first declare that Pin as an input.:
pinMode(8,INPUT);
So, that's all about today. I hope you have enjoyed today's tutorial and are gonna learn something out of it. In the next tutorial, we will have a look at
How to use DigitalWrite Arduino Command, which is used to update the status of digital Pins. Let me know if you have any questions in it. Take care !!! :)
How to use Arduino Serial Write?
Hello 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 it's named 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 a serial port in Arduino and for that, I am going to use the Arduino Serial Write command. It's also going to be 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 ???
- In the Arduino Serial Read, we have seen that How to read data coming from the serial port and we have used Pin # 0 for that purpose.
- So, now we are going to 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 a GSM module with Arduino then you have to send AT commands to your GSM board 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 and it sends 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 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.
Proteus Simulation
- So, design a Proteus Simulation as shown in the below figure:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(20, 4);
// Print a message to the LCD.
lcd.setCursor(1,0);
lcd.print("www.TheEngineering");
lcd.setCursor(4,1);
lcd.print("Projects.com");
lcd.setCursor(1,0);
Serial.begin(9600);
lcd.clear();
Serial.write('1');
}
void loop()
{
}
- 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 the below figure:
- 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 the Arduino Serial Write command:
Arduino Serial Write Syntax 2:
- We can also send a String of bytes 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 our site address on the serial port:
Serial.write ( "www.TheEngineeringProjects.com" ) ;
- Now let's sent a string of bytes 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:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(20, 4);
// Print a message to the LCD.
lcd.setCursor(1,0);
lcd.print("www.TheEngineering");
lcd.setCursor(4,1);
lcd.print("Projects.com");
lcd.setCursor(1,0);
Serial.begin(9600);
// lcd.clear();
Serial.write("www.TheEngineeringProjects.com");
}
void loop()
{
}
- Run your Proteus Simulation and you will get the below results:
- 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.
How to use Arduino Serial Read ?
Hello friends, I hope you all are fine and having fun with your lives. Today, I am going to share a very basic and introductory tutorial named How to use Arduino Serial Read. I am sharing this tutorial because I am getting a lot of emails in which users normally ask about basic Arduino tutorials as they are very new to them. So, I thought of sharing this very basic Arduino tutorial in which we are going to have a look at how we can use the Arduino Serial Read command.
I selected this tutorial as my first tutorial in this list of Arduino basic tutorials because learning to use Serial port is very necessary as it's one of the best troubleshooting tools for your code. I have also given a Proteus Simulation in which I have received the incoming data from the serial port and displayed it on LCD. Before going into the details of this Arduino Serial Read, let me first discuss the Serial Port in General.
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | LCD 16x2 | Amazon | Buy Now |
2 | Arduino Uno | Amazon | Buy Now |
What is Serial Port?
- I have already written a detailed tutorial on this topic which you can read at What is Serial Port?
- Serial Port is used for data communication between two electronic modules, both should support serial ports.
- Serial Port has 9 pins in total used for different purposes.
- The two of these pins most commonly used are TX (transmitter) and RX (Receiver).
- So, using these two pins we send our data from one place to another.
- Now let's have a look at Arduino Serial Port first, before having a look at Arduino Serial Read.
Serial Port in Arduino
- Almost all Arduino boards support Serial Port.
- If we talk about Arduino UNO, it has one serial port on it and it is located at pin 0 and pin 1.
- If you look closely at the Arduino UNO board then you can see a little TX is written on its pin # 1 and a little RX is written on its pin # 0, as shown in the below figure:
- So, now we have got the Serial Port on Arduino UNO which we know are at pin # 0 and pin # 1, now in the next part, we are going to have a look at How to use Arduino Serial Read and get data from this Serial Port.
How to use Arduino Serial Read?
- Arduino Serial read command is used for reading any data available at the Serial Port of Arduino board.
- I have also designed a Proteus simulation which you can download from the below button, and I have explained this simulation in the last step of this tutorial:
Download Simulation & Code
- For example, you have some serial module, let's say GPS module (most of the GPS module works at serial port).
- So, when you connect your GPS module with Arduino, you have to connect the TX pin of GPS with the RX pin of Arduino.
- Now the TX pin of GPS will be sending/transmitting the data and because this pin is connected with the RX pin of Arduino, so Arduino will keep receiving the data.
- Now the data is coming to Arduino but you have to write some code to read this incoming serial data and then save it in some variable.
- And in order to read this data, we need to use the Arduino Serial Read command.
- Arduino Serial read command reads the incoming data from Serial Port and then saves it in some variable.
- Here's the syntax of the Arduino Serial Read command:
char data = Serial.read();
- One important thing is, in order to make Arduino Serial Read command work, you have to first initialize the Serial Port in Arduino, as shown below:
Serial.begin(9600);
Note:
- Arduino USB Port which is plugged into the computer and is used for uploading code also works on the same serial port.
- So, if you have anything plugged in pin # 0 of Arduino then you can't upload the code in Arduino.
Now, let's design a simple example in which we will be receiving data from Serial Port and then saving it in some variable.
- So, connect your Serial device with your Arduino board and now upload the below code to your Arduino board:
void setup() {
Serial.begin(9600); // Serial Port initialization
}
void loop() {
if(Serial.available()) // Chek for availablity of data at Serial Port
{
char data = Serial.read(); // Reading Serial Data and saving in data variable
Serial.print(data); // Printing the Serial data
}
}
- Now, you need to open the Serial Monitor of Arduino which is used for debugging purposes.
- So, whenever you write something on Serial Port, it got printed on the Serial monitor.
- So, whatever you will be receiving in the Serial Port you will get in the Serial Monitor.
- Here are some random data of GSM module coming on serial port and showing in serial monitor:
How to use Arduino Serial Read in Proteus?
- So, now let's design a small Proteus simulation in which we will see how to use Arduino Serial Read.
- Proteus doesn't have Arduino boards in it, so you need to first download this Arduino Library for Proteus and then you will be able to simulate your Arduino board in Proteus.
- So, design a simple circuit as shown in the below figure:
- In the above figure, I have placed an LCD and I will get the data from the serial port and then I will print that data on LCD.
- So, in simple words, whatever I type in the Virtual terminal will be shown on LCD.
- You also need to download this New LCD Library for Proteus to get this amazing LCD in Proteus.
- So, now use the below code and Get your Hex File from Arduino Software:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(20, 4);
// Print a message to the LCD.
lcd.setCursor(1,0);
lcd.print("www.TheEngineering");
lcd.setCursor(4,1);
lcd.print("Projects.com");
lcd.setCursor(1,0);
Serial.begin(9600);
}
void loop() {
if(Serial.available()) // Chek for availablity of data at Serial Port
{
char data = Serial.read(); // Reading Serial Data and saving in data variable
Serial.print(data);
lcd.print(data); // Printing the Serial data
}
}
- Now when you start the Proteus simulation the first screen will look something like this:
- Now whatever you write in your Serial Port, will show on the LCD as shown in below figure:
- That's how the Arduino Serial Read works.
- You can download this Proteus simulation and the Arduino code by clicking the Download button given at the start of this post.
So, that's how you can use the
Arduino Serial Read command and can do your task. If it's still difficult for you then let me know on comments and I will try my best to resolve your issues. Thanks.
Line Following Robot using Arduino
Hello everyone, I hope you all are fine and having fun with your lives. Today, I am going to share a very basic project named as Line Following Robot using Arduino. I have designed a three wheeler robot and have placed IR sensors beneath it to detect the black line and then I have made it move over this Black Line.
This Line Following Robot is not doing any extra feature i.e. turning or rotating back. It will just simply move in the straight line. I have also posted a short video at the botton of this tutorials which will give you better idea of how this robot moves. You should first read this tutorial and design the basic robot and once you are successful in designing the basic Line Following Robot then you should have a look at my recent Project Line following Robotic Waiter in which I have designed a Robotic waiter which follows the line and also take turns on different tables. So, let's get started with Line Following Robot using Arduino.
Line Following Robot using Arduino
- First of all I have designed the Mechanical model of the robot, which has three wheels on it.
- Its a triangular method in which the motors were attached to the front two wheels and the back wheel is a caster wheel, which is present in the middle of the robot.
- Here's the image of front wheel coupled with the DC Gear Motor:
- Now let's have a look at the rear caster wheels, shown in below image:
- Finally, I have used Acrylic as the body of the robot.
- Here's the assembled version of our Line Following Robot:
- Now that we have the mechanical design of our robot and we have assembled it completely.
- So, now comes the electronics part where we are gonna place the DC Motor Driver Circuits and will also place the IR sensors.
- I have used Arduino board for programming of this Line following Robot.
- First of all, I have designed the 2 relay baord for DC motors.
- Its circuit diagram is shown in below figure:
- We also need a voltage divider circuit because we need such a power supply from which we can get 5V, while our source battery is of 12V.
- So, in order to do that I have used 7805 Regulator IC and have designed a simple circuit as shown in below figure:
- Now placing all the components over the Line following Robot, it looked like something as shown in below figure:
- Here's the Arduino code which you need to upload in your Arduino board:
#define motorL1 8
#define motorL2 9
#define motorR1 10
#define motorR2 11
#define PwmLeft 5
#define PwmRight 6
#define SensorR 2
#define SensorL 3
#define Sensor3 A0
#define Sensor4 A1
#define TableA A4
#define TableB A2
#define TableC A5
#define TableD A3
int OriginalSpeed = 200;
int TableCount = 0;
int TableCheck = 0;
int RFCheck = 10;
void setup()
{
Serial.begin (9600);
pinMode(motorR1, OUTPUT);
pinMode(motorR2, OUTPUT);
pinMode(motorL1, OUTPUT);
pinMode(motorL2, OUTPUT);
pinMode(PwmLeft, OUTPUT);
pinMode(PwmRight, OUTPUT);
pinMode(SensorL, INPUT);
pinMode(SensorR, INPUT);
pinMode(Sensor3, INPUT);
pinMode(Sensor4, INPUT);
pinMode(TableA, INPUT);
pinMode(TableB, INPUT);
pinMode(TableC, INPUT);
pinMode(TableD, INPUT);
MotorsStop();
analogWrite(PwmLeft, 0);
analogWrite(PwmRight, 0);
delay(2000);
// Serial.println("fghfg");
}
void loop() {
MotorsForward();
PIDController();
}
void MotorsBackward()
{
digitalWrite(motorL1, HIGH);
digitalWrite(motorL2, LOW);
digitalWrite(motorR1, HIGH);
digitalWrite(motorR2, LOW);
}
void MotorsForward()
{
digitalWrite(motorL1, LOW);
digitalWrite(motorL2, HIGH);
digitalWrite(motorR1, LOW);
digitalWrite(motorR2, HIGH);
}
void MotorsStop()
{
digitalWrite(motorL1, HIGH);
digitalWrite(motorL2, HIGH);
digitalWrite(motorR1, HIGH);
digitalWrite(motorR2, HIGH);
}
void MotorsLeft()
{
analogWrite(PwmLeft, 0);
analogWrite(PwmRight, 0);
digitalWrite(motorR1, HIGH);
digitalWrite(motorR2, HIGH);
digitalWrite(motorL1, LOW);
digitalWrite(motorL2, HIGH);
}
void MotorsRight()
{
analogWrite(PwmLeft, 0);
analogWrite(PwmRight, 0);
digitalWrite(motorR1, LOW);
digitalWrite(motorR2, HIGH);
digitalWrite(motorL1, HIGH);
digitalWrite(motorL2, HIGH);
}
void Motors180()
{
analogWrite(PwmLeft, 0);
analogWrite(PwmRight, 0);
digitalWrite(motorL1, HIGH);
digitalWrite(motorL2, LOW);
digitalWrite(motorR1, LOW);
digitalWrite(motorR2, HIGH);
}
void PIDController()
{
if(digitalRead(SensorL) == HIGH){analogWrite(PwmRight, 250);analogWrite(PwmLeft, 0);}
if(digitalRead(SensorR) == HIGH){analogWrite(PwmLeft, 250);analogWrite(PwmRight,0);}
if((digitalRead(SensorL) == LOW) && (digitalRead(SensorR) == LOW)){analogWrite(PwmRight, 0);analogWrite(PwmLeft, 0);}
}
- Now that's all, here's the video for Line Following Robot using Arduino which will give you better idea:
That's all for today. I hope you have enjoyed this Line Following Robot using Arduino and are gonna use it in your projects. feel free to ask in comments, if you got into any trouble. Thanks for reading. Take care !!! :)
LPG Gas Leak Detector using Arduino
Hello friends, hope you all are fine and having fun with your lives. Today, I am going to share a new project named LPG Gas Leak Detector using Arduino in Proteus ISIS. Before reading this tutorial, you must first download the Gas Sensor Library for Proteus because we are gonna use that Library and will simulate the Gas Sensor in Proteus.
In this library you will find eight sensors and all of them works exactly the same so that's why we are gonna use one of them. For LPG Gas Leak Detector Project I have used MQ-2 sensor which is used for detection of LPG gas. I have also used Arduino UNO board which you can simulate in Proteus using Arduino Library for Proteus. Moreover, I have also placed an LCD which will display either LPG gas Leak Detected or not. So, let's get started with LPG Gas Leak Detector using Arduino in Proteus ISIS.
LPG Gas Leak Detector using Arduino in Proteus ISIS
- First of all, download the Gas Sensor Library for Proteus and install it in your Proteus software so that you can it in Proteus.
- After installing the Gas Sensor Library, now download the LPG Gas Leak Detector Project's simulation and programming code by clicking the below button:
Download Proteus Simulation & Code
- Now, let's design this project so that you can get a better idea of how it works.
- First of all, design a small circuit in your Proteus software as shown in below figure:
- Now you can see in the above figure that I have used Arduino UNO board along with 20 x 4 LCD and Gas Sensor MQ-2.
- You can use this LCD by download this New LCD Library for Proteus.
- Next thing you need to do is to download the below code and get your hex file.
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
int Gas = 7;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(20, 4);
// Print a message to the LCD.
lcd.setCursor(0,0);
lcd.print("Gas Detected :");
lcd.setCursor(1,2);
lcd.print("www.TheEngineering");
lcd.setCursor(4,3);
lcd.print("Projects.com");
pinMode(Gas , INPUT);
}
void loop() {
if(digitalRead(Gas) == HIGH){lcd.setCursor(14,0);lcd.print(" Yes");}
if(digitalRead(Gas) == LOW){lcd.setCursor(14,0);lcd.print(" No ");}
}
- If you don't know about Hex file then read How to Get Hex file from Arduino Software.
- Upload this Hex File in your Proteus Arduino software and then run your simulation.
- If everything goes fine then you will get results as shown in below figure:
- So, you can see in the above figure that when Gas Sensor is HIGH then its written on the LCD that Gas Detected: Yes.
- Here's a video which will explain this LPG Gas Leak Detection using Arduino in Proteus ISIS:
So, that's all for today. I hope you have enjoyed this project named LPG Gas Leak Detection using Arduino in Proteus ISIS. Will meet you guys in the next tutorial. Till then take care and have fun !!! :)
GSM Based Home Security System
Hello friends, I hope you all are fine and having fun with your lives. Today, I am going to share a complete project named as GSM Based Home Security System. I have designed its complete working simulation in Proteus and have used different libraries which you can also download from our blog. In the previous post, I have posted Home Automation Project using XBee & Arduino and today we are gonna work on Home Security System.
We have designed this simulation after a lot of efforts that's why we have placed a very small amount of $50 on it so that engineering students can download it and get knowledge from it. Moreover, as its a complex project so when you buy it then there's a chance that you can't run it by yourself so we also offer a free service. If you got into any trouble while running this simulation then use our Contact Form we will help you out personally within 24 hours.
GSM based Home Security System
- You can buy this complete project by clicking the below button:
Buy This Project
- When you will click the above button, you will be taken to the sale page for this project and you can buy this project using PayPal.
- When you buy it you will get the complete code along with working Proteus simulation.
- So, let's have an overview of this GSM Based Home Security System.
- This GSM based Home Security System contains seven sensors which will be installed theoretically in your home. :)
- These seven sensors are:
- PIR Sensor: For Motion Detection.
- Smoke Sensor: For Smoke Detection.
- Flame Sensor: For Fire Detection.
- Vibration Sensor for Window: For Detection of vibrations on Window.
- Vibration Sensor for Door: For Detection of vibrations on Door.
- Ultrasonic Sensor for Window: For intruder Detection on Window.
- Ultrasonic Sensor for Door: For intruder Detection on Door.
- When we are talking about security then we have to take care of door and windows.
- That's why I have placed two sensors on each of them. If someone tries to break the window then the vibration sensor will sense it and if someone tries to open the window then ultrasonic sensor will detect it.
- The same will happen for the door.
- So, whenever any of these seven sensors will get activated then the buzzer will go on and at the same time the user will receive a warning message.
- Moreover, I have also placed an LCD which will display the sensors' condition.
- Here's the Proteus Simulation for this GSM based Home Security System:
- You can see in the above figure that I have used all these seven sensors mentioned above.
- Moreover, I have used the GSM module, you can read more about it on GSM Library for Proteus.
- Moreover, we have the Power circuit and the Buzzer Driver Circuit at the bottom.
- Arduino UNO acting as the brain of this GSM Based Home Security System.
- Now, let's run this simulation and if everything goes fine then you will get something as shown in below figure:
- First of all, the system will configure the GSM module and then it will display two screens on LCD side by side.
- First LCD screen is shown in below figure:
- The first screen will show the status of first three sensors.
- Now here's the screenshot of second screen showing the status for next four sensors:
- That's how this project is working, now when any of these sensors got HIGH then buzzer will go ON and a message will be sent to the given number:
- Now, you can see when I click the Smoke Sensor HIGH, it got detected immediately and a warning message is sent to my number.
- I have explained this GSM based Home Security System in detail in the below video:
So, that's all for today. I hope you guys have enjoyed this awesome project. Before buying it, you must read it completely and also watch the video so that you are sure about what you are buying.
Home Automation Project using XBee & Arduino
Hello friends, I hope you all are fine and having fun with your lives. Today, I am going to share a new Home Automation Project using XBee & Arduino. Home Automation Project is a most commonly designed project by the engineering students. So, that's why I have thought to create a complete Home Automation Project so that engineering students can get benefit out of it.
We all know about automation which is originated from automate or automatic. In automation the task is done automatically and you don't need to control it. In normal Home automation project, there are few sensors which are displayed wirelessly to user and there are few controls like user can ON or OFF Lights, Fans etc via remote or mobile App.
In this Project, I have used Arduino UNO board and I have designed its complete working simulation in Proteus software, so that users got sure that its working perfectly. Because we have to work a lot in designing this complete working simulation of home Automation Project that's why its not free but you can buy it for a small price of $50. In this price, you will get the compelte Arduino code along with the working Proteus Simulation. But before buying this project, must have a look at the details below so that you are sure what you are buying. So, let's get started with Home Automation Project using XBee & Arduino.
Home Automation Project using XBee & Arduino
- You can buy the complete working Proteus Simulation along with the Arduino Programming Code by clicking the below button.
- You can pay via Paypal and the download link will be instantly available to you and if you don't have the PayPal account then use our Contact Us Form and we will find some other way for you.
Buy This Project
1: Overview
- First of all, let's have an overview of this Home Automation Project.
- In this Project, I have designed two simulations, one simulation is for Remote using which we are gonna control our appliances and the second simulation is for the controlling of these appliances.
- So, when you press buttons from your remote section, a wireless command will be sent to the control board and it will turn ON or OFF the respective load.
- Moreover, there's an LCD on the Remote on which you will also check the values of the sensors.
- So, in simple words, the remote will be in your hand and using this remote you can easily turn ON or OFF your appliances and can also check the status of your different sensors wirelessly.
- Let's first have a look at the remote section:
Remote Control:
- In Remote Control Section, I have used the below main modules:
- Arduino UNO: Microcontroller Board.
- KeyPad: Commands will be sent by clicking this Keypad's buttons.
- LCD (20 x 4): For Displaying Sensor's Data & Commands.
- XBee Module: It's an RF Module used for sending wireless commands.
- Now when you click any button on your Keypad, a command is sent from Arduino to XBee Module and the XBee module then forwards that command to other XBee on the Control Unit.
- Moreover, when the Control Unit sends the Sensors' data on xbee then Arduino receives that data and then displayed that data on LCD.
- Here's the block diagram of Remote control section which will give you a better idea of its working:
- Here's the Proteus Diagram of our Remote Section:
- In the above Proteus Simulation of Remote Control, you can see that we have Arduino UNO board which is connected with LCD, KeyPad and XBee Module.
- Working of this Remote section will be discussed in the later section.
- Now let's have a look at the Control Unit Side of Home Automation Project.
Note:You must also have a look at below tutorials because I have interfaced these modules separately with Arduino as well:
Control Unit:
- In the previous section, we had an overview of the Remote section, now let's have a look at the Control Unit.
- The Control Unit is the Unit which is being controlled by the Remote Control.
- The Main components of Control Unit are:
- Arduino UNO: Microcontroller Board.
- Relays: Used to control the appliances. I have added eight relays so you can control eight appliances.
- Lamps: Indicating the Bulbs.
- DC Motors: Indicating the Fans.
- Smoke Sensor: Used to detect the Smoke.
- Flame Sensor: Used for Fire detection.
- DS18B20: Used to measure atmospheric temperature.
Note:
- On this Control unit, the Arduino UNO is getting the data from the smoke sensors and then sending this data via XBee to Remote Control.
- We have seen in the previous section that this data is then displayed over LCD.
- Moreover, when any button is pressed from the Remote Control, the command is received by this Arduino via XBee.
- On receiving this command, Arduino UNO then turns ON or OFF the respective relay which in turn ON or OFF the respective appliance.
- Here's the block diagram of this control unit:
- You can see in the above block diagram that I have connected three sensors with Arduino and Arduino is receving their values and then sending these values to the remote control via XBee.
- Moreover Relays are also connected to Arduino and then loads are further connected to these Relays.
- So, Arduino is controlling these Relays which in turn are controlling the loads.
- I have used eight relays and hence eight loads.
- The Loads I have used are all DC loads because Proteus doesn't have AC active loads in it but you can place AC loads as well.
- Here's the Proteus Simulation of Control Unit:
- You can see all the modules are present in it.
- Eight relays are present on the right side and their outputs are going into the loads.
- I have used four lamps and four DC Motors.
- Now let's have a look at their operation.
Note:You should also have a look at below tutorials in which I have interfaced these sensors separately with Arduino:
2: Operation
- I have already mentioned their operation in above section so I am not gonna discuss it in detail.
- But let's have a little talk about their operation.
- First I am gonna discuss the operation of Remote Control:
Remote Control:
- The remote Control has an XBee module which is used for wireless communication.
- The Keypad has buttons on it so now when you press button "1" on the keypad then the Signal is sent via XBee to Control Unit.
- The control unit will automatically turn on the first load when it will receive the command from button "1" of Remote Control.
- When you press "1" for the first time then the first load will turn ON but when you press button "1" again then the first load will go off.
- So, its like if you want to turn it ON then press it and if you want to turn it OFF then press again. (Quite simple :P)
- As there are eigth loads, so button "1" to "8" are working for loads "1" to "8" respectively.
- Moreover, when sensor's data come from control unit then it is updated in the LCD of Remote Control.
- Now let's have a look at the operation of Control Unit:
Control Unit:
- As the Control Unit is concerned, it keeps on waiting for the command from remote and whenever a command is received from the Remote Control, it turns ON or OFF the respective load.
- Moreover, it also sends the data of sensors continuously to the Remote Control.
- For this wireless communication, XBee is used here.
3: Working
- This is the last section of this project where will will have a look at the working of the project.
- I haven't divided this section in parts instead I have create a video which will explain the working in detail.
- Here's the First look of Remote section image while working:
- Now when the Sensor's data come from the remote Section then it will be displayed in the LCD as shown in below figure:
- You can see in the above figure that both sensors are detecting and the temperature is also displayed in the LCD.
- Now the complete working of this project is shown in the below video which will give you complete idea of this project:
Note:
- If you buy this project and you are unable to run it properly then we will provide you free service and will make it work on your laptop perfectly. :)
So, that's all for today. I hope you have liked this Home Automation Project and are gonna buy this one. But again before buying it must read this tutorial and also watch the video so that you get complete understanding of this project.
Interfacing of Flame Sensor with Arduino
Hello friends, I hope you all are fine and having fun with your lives. Today, I am going to share a new tutorial which is Interfacing of Flame Sensor with Arduino. I have recently posted a tutorial in which I have shared the Flame Sensor Library for Proteus. Now in this tutorial, I am gonna use that Flame Sensor Library and will interface this Flame Sensor with Arduino. So, if you haven't downloaded this file then I suggest you to download this Flame Sensor Library so that you can easily simulate this flame Sensor in Proteus.
I am sharing interfacing of this Flame Sensor with Arduino today, but soon I will also post a tutorial on Interfacing of Flame Sensor with PIC Microcontroller. If you guys have any questions then ask in comments. I have also given the Simulation file and the Programming code below to download. But I would recommend you to design this proejct on your own so that you make mistakes and then learn from them. So, let's get started with Interfacing of Flame Sensor with Arduino:
Interfacing of Flame Sensor with Arduino
- You can download the complete Proteus Simulation along with Arduino programming code from the below button:
Download the Simulation
- Now design a small Arduino code as given below:
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
int Flame = 7;
void setup() {
Serial.begin(9600);
pinMode(Flame, INPUT_PULLUP);
lcd.begin(20, 4);
lcd.setCursor(0,0);
lcd.print("Flame : ");
lcd.setCursor(1,2);
lcd.print("www.TheEngineering");
lcd.setCursor(4,3);
lcd.print("Projects.com");
}
void loop() {
if(digitalRead(Flame) == HIGH){lcd.setCursor(8,0);lcd.print("Detected ");}
if(digitalRead(Flame) == LOW ){lcd.setCursor(8,0);lcd.print("Not Detected");}
}
- Add this code in your Arduino software and compile it to get the Hex File from Arduino Software.
- Upload this hex file in your simulation and then run your simulation and if everything goes fine then you will get something as shown in below figure:
- In the above figure, you can see the sensor is off that's why in the LCD its written that no smoke detected.
- Now, let's bring some Flame by clicking the Logic State on Flame Sensor and you will see the below results:
- Now you can see in the above figure that when the Flame is detected then the LCD indicated that Flame has detected.
- That's how we can easily simulate the Flame Sensor with Arduino.
- I have explained this project in detail in the below video:
That's all for today. I hope you have enjoyed this project and now you can easily interface your Flame Sensor with Arduino in Proteus ISIS.