Arduino Long Distance Communication | Ashraf Madhoun | Skillshare

Arduino Long Distance Communication

Ashraf Madhoun, An Engineer with +10 Year Experience

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
8 Lessons (58m)
    • 1. 1 Introduction

      4:16
    • 2. 2 Hardware and Software Requirements

      1:09
    • 3. 3 What is RS485

      4:04
    • 4. 4 Circuit Connection

      6:05
    • 5. 5 Coding Transmitter and Receiver

      15:02
    • 6. 6 Arduino Long Distance Wireless Communication

      6:05
    • 7. 7 Circuit Connection

      5:55
    • 8. 8 Coding

      15:46

About This Class

Arduino Long Distance Communication

Start Sending Data Over Long Distance using Arduino via Wired and Wireless Connection and extend Arduino Capabilities

What you'll learn

  • Make your own Arduino Long-Distance Transmitter and Receiver
  • Learn what is the hardware required to make this happen.
  • Learn what is RS485 and how to implement this communication protocol in long-distance communication.
  • Dake down the schematic for connecting Two Arduinos using RS485 protocol over long-distance.
  • Discuss the receiver and transmitter program for RS485.
  • Talk about the circuit assembly and we will break down the HC-12 module working principle for long-distance wireless communication between two Arduinos.
  • Perform communication of the Arduino to Arduino using the HC-12 module.
  • Explain how communication works with Arduino transceiver.
  • Create a PCB for this project

Description

>>> Start Sending Data Over Long Distance using Arduino via Wired and Wireless Connection and extend Arduino Capabilities  <<<

Welcome to this course.

This course will teach you how to Make Long-Distance Communication between Two Arduino Boards using Wired and Wireless Connection, This Guide will take you in a step by step manner to know what are the needed components, why we use them, and how to wire them up, starting with the basics of Arduino Serial Communication and ending with Sending data over a very Long distance.

You will know what is the actual working principle of Long-Distance Communication, what are the right communication protocols to be used, and how to interface the required module to make this happen.

We know that Arduino has several built-in buses for fast data transfer, for example, The SPI Protocol and I2C Protocol. Various kinds of sensors are often connected using the I2C communication protocol.

There is also the popular UART universal asynchronous receiver transmitter protocol, which is often used with a USB interface to exchange data with a laptop or computer. But all of these methods have a serious drawback. They do not work at large distances.

Imagine a situation where we need to collect data from sensors on the roof of our houses and depending on the location of the sensors, our hardware, and software setup, we need to transfer a signal from this sensor to our Arduino on the first floor.

How can we make it possible? We'll definitely need a powerful Long Distance Transmission method, one that can be used for years, and in this course, we will cover this, we will cover wireless and wired long-distance communication methods between two or three Arduinos or any two microcontrollers, whether they are Arduino microcontroller or any other types of microcontrollers.

We will make it as simple as possible.

What you will learn in This Course

  • Learn what is the hardware required to make this happen.

  • Learn what is RS485 and how to implement this communication protocol in long-distance communication.

  • Dake down the schematic for connecting Two Arduinos using RS485 protocol over long-distance.

  • Discuss the receiver and transmitter program for RS485.

  • Talk about the circuit assembly and we will break down the HC-12 module working principle for long-distance wireless communication between two Arduinos.

  • Perform communication of the Arduino to Arduino using the HC-12 module.

  • Explain how communication works with Arduino transceiver.

  • Create a PCB for this project

I'm sure that you will gain a lot of knowledge in this course.

Who this course is for:

  • Anyone interested in making his own Arduino Long-Distance Transmitter and Receiver
  • Anyone interested in making amazing Microcontroller Projects
  • Anyone Interested in Learning How Long-Distance Communication works
  • Anyone Interested in Learning Wired and Wireless Long Distance data Transmission
  • Electronics Geeks
  • Arduino Geeks
  • Anyone Interested in Learning New Things about Arduino
  • Anyone Interested in Microcontrollers

Transcripts

1. 1 Introduction: Hello and welcome to this Senior Corps in your Chu layer. Long distance here I'll communication between two Arduinos. And this is Asherah from educational engineering team. We know that Arduino has Cithaeron built in buses for fast that transfer, for example. And this ablaze usually use the SPI protocol. Various kinds of sensors are often connected using the I squared C communication protocol. There is also the unpopular your AR, or universal asynchronous receiver transmitter of protocol, which is often used with a USB interface to exchange data with a laptop or computer. But all of these methods have a serious drawback. They do not work at large distances. Imagine a situation where we need to collect data from sensors on the roof of our houses. And depending on the sensor's location or depending on our hardware and software setup, we need to transfer a signal from this sensor, all of these sensors to our Arduino on the first floor. How can we make it possible? Will definitely need a powerful noisy resistance interface, one that can be used for years. And in this course we will cover these. We will cover wireless and our long distance communication methods between two Arduinos or any two microcontrollers. Whether they are Arduino's Beck lay controller or any other type flight controllers. Now, we often want to perform remote actuation of civil actuators, such as lamps, mortars, and other actuators. And getting this done from a distance is a bit hard job or a bit complex job. So in this course, we will make it as simple as possible. Now, what you will learn in this course, you will learn what's the main working principle behind long distance Sierra communication between Arduinos. You will learn what are the hardware required to make this happen. You will layer what is RS 485 and how to implement this communication protocol and your long distance serial communication. We will take down the schematic for connecting to Arduino's using us for 85. And this Ci, communication protocol is our long distance communication between two Arduino's. After that, we will discuss the receiver and transmitter, a program for RS 485. In the second part of the course, we will talk about the Circuit Assembly and we will break down the HCI 12 module working principle for long distance wireless serial communication between two Arduinos. We will perform communication of the Arduino to Arduino using the MHC. Two will module. And after that we will discuss remote device activation. We will understand, we will explain how CSR communication works with a radio transceiver. The last step we'll be creating a PCB for our project. Again, in this course, we will cover both wireless and wired long distance communication methods. I'm sure that you will get a lot of knowledge in this course. So stay tuned and see you inside. This is Asherah from educational engineering team. 2. 2 Hardware and Software Requirements: Required hardware and software for the scores. First, you will need Arduino bond, and you will also need PC or laptop. We will use Arduino IDE to arrive the cones. And we need a breadboard to connect components. You will need to Arduino's, as we mentioned. And you will need to RS four 85 module for the wire serial communication section of this course. You will need the FC 12 module for the wireless long distance serial communication section of this course. You will need a breadboard and some wires. That's it for that required hardware. And regarding that software, we will only need Arduino IDE and a circuit design software which is rising and who are gong to exhibit how to download and install Each of these softwares. Thanks for watching this lesson. See you next. 3. 3 What is RS485: What is RS 485 is four. 85 is a serial interface, which is the predecessor is 2.3.2. This module gained fame because of the comb ports of all computers that just work on the RS232 interface. And in this picture you can see the R is for 85 module that you can interface with your Arduino boards. The maximum range of the r is for 85 module is a 100 or one hundred and two hundred meters, which means we can expand our signal up to 1.2 kilometers. If there are special amplifiers on the line, it can extend even further. That transmission speed over such a long wire will be about 16 kilo byte per second, which is a relatively good speed for transmitting the sensor's data. Now, I twisted pair cable is used for the R is for 85 cable, and you can purchase it online. This cable is still used ethernet lines. So you can get an ethernet cable and use it with your r is four 85 module, making it easily available to transfer data at a distance of more than 500 meters. You will need a shielded twisted pair. And a shielded twisted bill is basically at roasted bird cable that has a shield around it to protect it and to enhance the signal. 32 devices can be connected to one cable, but at the same time, only one device can transfer data. So now you can't transfer data up to 1.2 kilometers and you can connect up to fail to two different devices. The R is for 85, has been used since the late nineties in a variety of industrial systems, where data needs to be transmitted over long distances. In the presence of electromagnetic interference. As r all the r is for 85 interface is used together with specialized protocol such as mood bus or dram x 512. But the most common one is mod bus, and it mostly used, it's mostly used in the PLC is all of our PLC industrial. Now, what I want you to understand from this lesson is that this is the R is for 85 module. And you must connect it using a twisted pair cable, just like the one that's available on the market for the internet, it's called ethernet cable. And you can connect up to 32 different devices using this protocol is for 85, but only one device can transfer data. You can't connect to devices with a distance of 1.2 kilometers without any issues. That's it. If you have any question about this module, I'll be more than happy to help you. In the next lesson, we will explain the circuit design and how to connect this module to Arduino ball or two, both are real balls. We will need two modules and how to connect them together. We will take a deeper look and the requirement. We will take a deeper look and we will discuss the required cable. I will show you some pictures for that cable so that you can get it from anywhere, either online or offline. Thanks for watching this lesson. This is Asherah. 4. 4 Circuit Connection: Hello and welcome to this new lesson in which we are going to discuss the arduino and HCI 12 long-range wireless communication module. Now, in this course and in this section of the course, we are going to take an example where we are going to send data from one algorithm to another wirelessly using the FC 12 long-range wireless module. And we will explain how to make a basic communication between the two boards. Now, Let's get started by taking a closer look at their seat. Well, wireless serial ports communication would you hit? It works with wireless working frequency band from 433 megahertz. So 470, three megahertz. It has a total of a 100 channel. And these unsocial, you can switch between them. That transmission power is very low, it's about 0.79 milliwatts, and the receiving sensitivity is from minus a 117 dB to minus 100 dB. And this value varies depending this table. Now these values actually depend on the selected cereal and over the air baud rate, as seen in this table. As you can see that it's evil sensitivity varies from minus 100 dB to minus a 117 dB. We need to know exactly how this module will be connected. And to know this, we need to know that bring out, as you can see, this is the module. And from the left to the right, this spin is number one. Let me use the pen. This one must be connected to five volts. And the second then must be connected to ground. The third and the fourth pin will be connected to Arduino. These are the RX and TX for serial communication. And the fifth one will be connected to Arduino as well. This is the CIT pin that can be used to configure our HCI 12 module. Now, one piece of information that is really important and you need to know is that the HCI 12 module has a microcontroller which actually doesn't have to be programmed by the user. For configuring them module. We simply use 80 commands which can be sent from an Arduino UPC or any other microcontroller using the serial port. Now for entering the AT command mode, we just have to sit, sit pin, which has been number five, this one. This one. We need to set it to allow logic level. So we need to connect it to ground. Once it's connected to ground, this module then turn on microcontrollers, will know that we are sending control commands to change the configuration for this module. Now, you can use this module using the or its default configuration data, which is basically the mood called a few 39,600 bits per second baud rate and channel 0.01. Now, these are the default configuration. If you want to choose any other mode, you can. And this can be done using the asset Ben. And by connecting this module using Arduino to your computer or by sending a superman serially using any of the options that we already mentioned. Again, the default configuration for this module is the a few three, which is basically mood number three. And number three, we are connecting this module to channel one. And this module is fully automatic and transparent to other devices sitting that adapts to the transmission rate of the connected device. Over 9,600 baud rate is still required to bull run it in command mode. So you'll need to make sure that you are going to program it. You need to choose 9,600 baud rate R. This mood. Note that as the transmission rate increases, the sensitivity of the receiver decreases and you cut it down to the table that we just discussed few seconds ago. And you can return to the default state by sending 80 by default command to your module. Now, in this lesson we are not going to discuss how to configure them, Would you all sense we don't need to change the configurations. If we looked at the data sheet for this module, I'll provide it and there are sources for this course. You can see that we have three modes. And this one is the default one. The ideal current consumption is 16 milliohm. And that one's machine time delay is four to 80 millisecond. Paulson doing one byte. Now, these are technical information and if you need the IAT commands, you can find them at birth or sheets. As you can see, these are the 80 commands that you can also change the configuration for this module. But if you are just getting started under fuel, dont want to go in depth with how to change all choose different modes from a few 123, you can't simply leave it are the default values. In the next lesson, we are going to connect the modules or Arduino ball. And we are going to start coding the first Arduino board and the second Arduino board. Thanks for watching this lesson. This is Ashley. 5. 5 Coding Transmitter and Receiver: Hello and welcome to this new lesson. No2 will discuss the coding process for the two Arduino's to get them ready to send that or to send and receive that. Now, as we have already mentioned, if several devices are connected to the line, only one device can transmit data at a time. So if another device needs to transmit data, it needs to wait for the first device to finish. We need to inform all other devices that we are ready for transmission and they must remain silent and listen. This can be done with the help of the pens. D and D is the drive or enable, R, E is the receiver. Enable. Now we will write two codes. One will broadcast a message or a text or whatever you want. Let's say that it will broadcast password every second or every 2.5th. The other device will listen to the broadcast of the message. And when it received the text or the message password, it will turn the lid number 13, which is the built inlet Arduino on and off. Now, to get started, let's first open up arduino. Now create a new sketch. This is our new sketch. Now we will start with the transmitter program, as it will be easier than the receiver program. The first step will be inside the void setup, initializing the Serial library. So serial.begin and at a baud rate 9,600. And now here we are sitting the serial port baud rate 29,600 pushes the speed of transmission. After that, we need to choose the bend moons for pin numbers to it will be output. And then number two, we'll switch receiver, transmitter mode. And this is why you are going to use it. And in this picture, who are connecting these two bins and the driver enable and they'll see your integral to pin number two, which is D2. Now, after doing this, we need to put the device in to transmit our mood. And to do that, we simply need to use the digitalWrite function. Now, inside it, we need to define the pin number, which is two. And here we need to put the device into transmitter mode and to play with. Place the device and the transmitter mode we need to send Hi. This is the first step. Now, we must go inside the void loop and send the message serial.print. And inside it will arrive password. We will add a delay. And in my case, let's make it 600 milliseconds. That's it. This is the transmitter program, so let's save it. Let's name it forward. Let's call it transmitter program. Now let's combine it to make sure that it works. Done combining. Now we need to create, that'll see var quote so far knew this is the new sketch. Let's save it. Let's name it receiver codes. Now. First we need to create a buffer and which we will receive the incoming data. And let's make it 200. The second step is called data. Before. The second step will be creating a state in which we will solve the states. Now, let's go inside the void setup. First we need to initialize the serial communication. Have the same both rates. You need to make sure that it's the same baud rate. Then we need to send them in mood for the lid, which is been number 13. It will be output. Next when to send to set the pin mode. For the second pin, which is D2. As we already mentioned, that's connected to the receiver enable under the rival in April. And we need to make it outward. The last step would be to put the device into the receiver ruled by digital rights. Now inside it, we set the pin number, which is two, and we need to send hello signal. And we already mentioned that this transmitter Arduino transmitting, transmitting device into the transmission mode, we need to send pi. And here we are, since they're both in the algorithm, the receiver mode, that's why we are sending low. So high is for transmitting and law is for a ceiling. Now, this will put the device into the receiver moves inside the void LW, we need to first initialize a variable. Let's call it j. Now we need to ask a very Sierra communication or not. And we can do that by using the serial available function. Now, if there is serial communication available, what we need to do symbol. First, we need to it. And let's say that you want to wait for ten milliseconds. And this is because we want to make sure that we are getting the entire data, all the full data bucket that was received by the boast. After that, we will use y. And basically we will ask while Serial available, while there is available Sierra communication and incoming data using the serial line, we to read it to the data buffer using the serial function. And since this is an array, it will start with 0 and we need to increase the index. And we already define the index to be J, and we give it an initial value of 0. So here we will derive j plus plus to keep storing the incoming data. Now this will read data and write it to the buffer. That's it. Now we are done with the serial part of the codes. The next tip after doing this is basically asking if data came and this value of J increased. So if j is more than 0, there is something in the buffer. What we need to do is basically convert the buffer content to our string by adding an old character. And this can simply be done by writing buffer j plus, plus. And here we'll add slash 0. This one, this one. Now this will confer the MAF, our content, our string by adding null character. After doing this, we need to ask using if statements. If the buffer, okay, it's called data before. If the data buffer equals and to compare them. Takes inside data by far was this text password, we need to use the STR CMP, which is basically a string compare function to compare these two strings. And if these two are equal, the if statement will be true. And in this case we need to write high on pin number 13. And this will turn this the internal Arduino pin on. Now, to turn it off, we can't simply either delay for 500 milliseconds and we can cope with this fixed based. It's here then Thermidor. That's it. Let's verify to make sure that we don't have any arrows compiling. Okay, here we have an error and we need to fix it. Now let's zoom out. Ok then combining. It was like a warning. Okay, okay, okay. Now let's verify it again. Done compiling. So it did show us our earning here goes we use this line, but it's skipped it. And after that, it compiled the code. So now we have a hex file that we can use. Now to fix this wording. Let's move this space and verify our code again. As you can see now done compiling. And that's it. This is not a civil code. Again, this exhibition, What we have done here, we created a buffer to store the incoming data. And this is not necessary. And we started by Sierra communication protocol at 9,600 baud rate. We enabled or we did sit the internal lid, which is our pin number 13, as an output. An output. And we placed the number two, which is connected to and the driver enable and disable or enable as an output. And we sit this Arduino to be in the receiver mood by setting Brin number too low. After that, we created an index for the buffer array. We checked if there is incoming serial data, we add a delay to make sure that we receive full buckets of data. Then we use the while statement to receive the incoming data and store it inside the data buffer. And as you can see, it will keep storing the incoming data using the serial read function until there is no data coming. Once it receive the full bucket of data, we are going to check if there is data inside the data buffer using this if statement. And if there is data, we will convert it to a string by adding this null character to the end of our array. And we will check if the data buffer, all the text inside of there from afar equals password, which was sent by the transmitter. And if it does, we will turn the lid on pin number 13 on, then we will turn it off. That's it. This is the receiver and this is the transmitter code. It's a very simple, easy as threat for or you can send different things here. 1234, uncheck using if statements. And the other side, if one is received turn-on something, if two's received, turn on other thing. Or you can send a variable here, which is, since we're reading, everything is straight forward from here. You just need to upload the code to your Arduino. Arduino will be your transmitter and the second one will be a receiver. Thus launching this coding lesson. If you have unquestioning governing anything, please ask in that you're on the board. And this is Asherah from educational engineering team. 6. 6 Arduino Long Distance Wireless Communication: Hello and welcome to this new lesson in which we are going to discuss the arduino and HCI 12 long-range wireless communication module. Now, in this course and in this section of the course, we are going to take an example where we are going to send data from one algorithm to another wirelessly using the FC 12 long-range wireless module. And we will explain how to make a basic communication between the two boards. Now, Let's get started by taking a closer look at their seat. Well, wireless serial ports communication would you hit? It works with wireless working frequency band from 433 megahertz. So 470, three megahertz. It has a total of a 100 channel. And these unsocial, you can switch between them. That transmission power is very low, it's about 0.79 milliwatts, and the receiving sensitivity is from minus a 117 dB to minus 100 dB. And this value varies depending this table. Now these values actually depend on the selected cereal and over the air baud rate, as seen in this table. As you can see that it's evil sensitivity varies from minus 100 dB to minus a 117 dB. We need to know exactly how this module will be connected. And to know this, we need to know that bring out, as you can see, this is the module. And from the left to the right, this spin is number one. Let me use the pen. This one must be connected to five volts. And the second then must be connected to ground. The third and the fourth pin will be connected to Arduino. These are the RX and TX for serial communication. And the fifth one will be connected to Arduino as well. This is the CIT pin that can be used to configure our HCI 12 module. Now, one piece of information that is really important and you need to know is that the HCI 12 module has a microcontroller which actually doesn't have to be programmed by the user. For configuring them module. We simply use 80 commands which can be sent from an Arduino UPC or any other microcontroller using the serial port. Now for entering the AT command mode, we just have to sit, sit pin, which has been number five, this one. This one. We need to set it to allow logic level. So we need to connect it to ground. Once it's connected to ground, this module then turn on microcontrollers, will know that we are sending control commands to change the configuration for this module. Now, you can use this module using the or its default configuration data, which is basically the mood called a few 39,600 bits per second baud rate and channel 0.01. Now, these are the default configuration. If you want to choose any other mode, you can. And this can be done using the asset Ben. And by connecting this module using Arduino to your computer or by sending a superman serially using any of the options that we already mentioned. Again, the default configuration for this module is the a few three, which is basically mood number three. And number three, we are connecting this module to channel one. And this module is fully automatic and transparent to other devices sitting that adapts to the transmission rate of the connected device. Over 9,600 baud rate is still required to bull run it in command mode. So you'll need to make sure that you are going to program it. You need to choose 9,600 baud rate R. This mood. Note that as the transmission rate increases, the sensitivity of the receiver decreases and you cut it down to the table that we just discussed few seconds ago. And you can return to the default state by sending 80 by default command to your module. Now, in this lesson we are not going to discuss how to configure them, Would you all sense we don't need to change the configurations. If we looked at the data sheet for this module, I'll provide it and there are sources for this course. You can see that we have three modes. And this one is the default one. The ideal current consumption is 16 milliohm. And that one's machine time delay is four to 80 millisecond. Paulson doing one byte. Now, these are technical information and if you need the IAT commands, you can find them at birth or sheets. As you can see, these are the 80 commands that you can also change the configuration for this module. But if you are just getting started under fuel, dont want to go in depth with how to change all choose different modes from a few 123, you can't simply leave it are the default values. In the next lesson, we are going to connect the modules or Arduino ball. And we are going to start coding the first Arduino board and the second Arduino board. Thanks for watching this lesson. This is Ashley. 7. 7 Circuit Connection: Hello and welcome to this new lesson in which we are going to design our circuit for the long distance wireless communication between two Arduino boards. Let's start by going to the start menu and open up fertilizing software. Now, freezing software is basically a circuit design and connection software. And this software will help us demonstrate how we are going to connect our circuit. We will start by adding the necessary components and go to the breadboard mode, and from there go to the Arduino. Now we need to add to Arduino boards. This is the first one, and this is the second one. And it's more this. Ok. Now the next thing that we need is the HCl molecule. So light edge C 12 and outer space. As you can see if we locked here, we don't have their seat world by default here. And if you follow it using wireless, you will most likely you won't find it. Now, to find this module, we need to do the following. We need to go to Google.com and write hc 12th flight zinc. And as you can see here we have it. It can broadcast information up to 1.8 kilometers. And all what you need to do is simply download the library. Now here it is, this is the module, and here are the files. Now, simply click in this module. And you can even give the antenna. Now here we have two files. And these are the files. We can simply drag these files on, throb them here. First of all, this again. To open these files, we need to go to File Open and go to this area. Now, as you can see, once you drag items and drop them here, you can easily insert them into your design. Now we need to modules one here and the other one right here. And this all data renal. Okay? Now let's start with the first one, which is this one. Now lets rotate this and make it closer to our Arduino balls here it is. Now, connect that TX pin, which is this spin to Ben, let's say number seven. And connect the RX pin to pin number eight height here. Now, the next step will be connecting the ground pin to the ground. And we also need to connect that VCC pin to the five volts from all Arduino board. Now this shows the coloring or these two pins. Listen the following for these tools up. Now, you can connect with their sit bin, which is basically this Ben. To UNI off your Arduino bends. If you want to configure your Arduino board, all your HCI module using your arduino. Now we will do the same thing here. We will rotate this by 90 degree by a 190 dx. The number seven are excellent. Bin number eight set would be number one and ground with the ground and VCC with five volts. This is red, this will be an Black. And this shown the hanging folder is to agree. Okay, now we can connect. Let's move this down a little bit. And now we can connect this spin to learn. And we can do the same here. Okay, I connect this antenna by Ts. And we are good to go. These are the two boards and they are under a duty to be full band. And this is the connection. Now, you need to make sure that you write down the pin number. We have one or 0, d 0, D7, D8. And here we have these year-old D7, D8. We will go back to our design, but let's save it and finished this lesson. And the next lesson, we are going to code certain design. We are going to code both of these Arduino boards. And let's save this as an image explored as image, and save it as b and g. And that's it. Thanks for watching this lesson. If you have unequal, please ask in that Randy abolished. 8. 8 Coding: Hello and welcome to this new lesson. And we're going to code our Arduino balls for long distance wireless serial communication. Now let's start by opening up Arduino software. After that, create a new sketch. As you can see here. First, we need to include the serial software library to be able to use and in digital pen as our TX RX pin to be used as that a transmitter. So right hashtag include software, serial LaTex. Now we create an object with a bends that will perform the serial communication. And this is a valid symbol step. You can do it by simply writing software serial FC 12. And here we will install the pins that we just connected in the previous lesson. Now, we named pens using defined, and we can choose any pins. In this circuit. We are going to add two buttons. And once we click on any of these two buttons, will send a wireless signal to the other Arduino board to turn on a specific lid. So let's use that defined function. P. First, Ben. Let's call it First button. And let's add the numbers two and use again define second button. Let's use bin number three. That suits. Now in the void setup function, pins numbers 23 are configured as input, so we need to write pinMode. And inside it we will write first button input. And we will do it again, then moods. Second button. And now we also need to configure the serial communication speed over USB and of the serial communication with HC-06 module. And to do that, we can't simply by the following criteria, look bigger. This will suit the baud rate for the USB port. It would be 9,600. The second one will be h c, it will begin and it would be 9,602. Now, after making the settings in the void setup function. We need to go to the void loop function, which is where the logic of our program happens. In the void loop function will read the buttons using digital reads. So going here, we will use digital reads. And digital read. We'll take the first button as input. And we are going to ask using if statements. If first pattern change did change, first button state changed, we need to perform an action, let's say solace R2 curly parentheses. Now, if the first button is pressed, it will send the value one to our SC2 module, so that the module transmits this information to the receiving edge suit HCI 12 through the air electromagnetic waves. So basically what we are doing here, we are checking if the button is pressed, we are sending something using the wireless module to the Arduino board. So if digital read first button was pressed, cereal, we will rent align. And I'll serial communication window here. First Clotel has pressed. Now after sending this line to the serial monitor, we need to print some serial.print. And we will send one, will also send one to the edge C module. That's it. Now, as you can see, this is the first if statement. Now at the end of the if statement, we can add a symbol while statement to make sure that we will keep breathing until the state of our button change. So we'll add these reads. Fairs button equal, equal 0. So it will keep breathing the first battle states. And when it does change, it will stop sending one. Now this is the first code. Let's verify to make sure that works. Let's call it that sendall codes. All transmitter. Okay, let's first change double two, okay? Now it's outdoing Ohno. And here we need to see what's happening. We have an error, okay? We shouldn't semicolon at the end if I define line than combining, now we can proceed. Who will do the same thing for the second button, what we are going to do is simply ask using if statement. So if digital reads will cope with this, will be the Han court. And at adheres to save time. And here we will change first button with second button. And we will send to, That's it. Let's combine the code done compiling. Now we will create other chords. Find new bucket lists could be this cold, and let's go to File New. Let's this the codes here. Now what we need to do here is remove these lines. These lines we will keep the if statements. Or maybe we can change this with switch statement. Okay, this is the second clause. We need to show that these here we have our red LED and our blue lid. We will connect them to pins number 34. Now, we will leave this because we need them and receive our side because we wanted that software Syria. And you have connected it to Ben's number 78. Now, the next step will be defining a galactose to store that are received value. Now, inside here, we need to change this to red. And the blue lids. This will be output. This will be our now cURL began. We will leave it on this line. We will leave it to. Now we can write here serial, print n receiver. And we can't even turn the lids on and off as indication that Arduino is working just fine. So what I've digital polite and delay 500 millisecond. And here we can blue lives. Here do we have alluded? Okay, we have one or high. Then Colby and these two lines and paste them here. Now it will be low. This will turn that bullet on and off to indicate that our circuit works just fine on the code works just fine. Now, inside the void Lu, first listen all these lines. Now the loop is empty. We will ask using a while statement that a serial communication. Or serial data coming or not. Now this can be done using the available function f, c. It will available function now with has a value bigger than 0. And this means that there is incoming data on the serial line. And we need to store inside the receive character that we just defined here. And we will use the function reads to read the incoming data. After that, we will print out the incoming data. Then we are going to use switches statement to check the incoming data fit equals one or two. And to do that, we can't simply write switch statements. Case one, break. After that case to break. Now, case one, we need to Hernan thus created lids, which is the ribs. Lead. It's basically okay here we have no learned here, have read lid and dual it, okay? Now the red LED, we need to send the value the that'd live. And this value will be tough. Regions. For Red's. Not. Now what this line means, we call it high or low here. But it won't be convenient. What we are doing here is basically we are writing the opposite of the value that's available on this pen, which is a red LED. Now for the red LED pin is on, it will turn it off. If they're lid lid pin is off, it will turn the LED on. So whenever we receive one, this line will reverse the state or the status of this red lead. If it is on, it will be all for this. The off it will be all. This is done using this sign. This will reverse the status. And this will be the status of that is if it is on. So not on means off, and not off means on. Now, this is exactly what we do. Now, if I wrote not 0 and this equals one. If i said not one, 2l equal 0. And this is exactly the same thing, but here we are using the life, the life value from our lids. So if our red LED is on, once we press the button on the first Arduino, it will send one. And it will turn the LED off. If our lead us off. Once the button is pressed on the first Arduino, it will send one. And this will reverse the status of outdoor lids, which we'll turn it off and so on. Now, the same thing, the same line can be used for the second case. But here when you try to blue LEDS, as you can see now, the blue LED will turn. If it is on, it will be offered. If it is off, it will turn on. Now let's verify the code and let's call it love. The transmitter. Or a c bar, sorry. Nafta is done combined. Ok, here we have an arrow. Here, we need to use a blue LET. Okay, after, let's capital letters. So rulers, rulers, rulers need to make sure that we don't have any spelling errors done combining. Now, done combining means that everything is working just fine. You can use these two calls and upload them to your Arduino balls. And they will work just fine. And you can adjust them depending on your needs. If you did everything right, you can't transmit that are up to 1.8 kilometers wirelessly using these two albino bolts. So it's up to your configurations and your application. If you have any question or of a few faced any problem you can ask in that land they bore. This is Ashraf.