Interfacing Arduino with HC-05
Hello friends, i hope you all are fine and enjoying. Today i am going to share a new tutorial which is Interfacing Arduino with HC05 Bluetooth module. First of all lets have a little introduction about HC-05 Bluetooth module. HC-05 is a bluetooth module, which was designed for wireless data communication. This little module is capable of both sending and receiving data but it performs only one thing at a time, which means at a particular time it can only send or receive data but can't do the both tasks.
In order to send or to receive data, you have to make one module as a master and the other module as a slave. If both the modules are acting as master then, data will not transmit and if both the modules are acting as a slave then, again data will not transmit or receive. The hardware of Bluetooth module contains a large no of features. For example it is much sensitive and it is sensitive up to -80dBm and it catches a Bluetooth signal even from far away. If you wish to transmit data through it then, it also have much power to transmit data to a wider range. You can image its transmitting power from the digits that it has transmitting power of +4dBm. This module operates on a low voltages, that's why the power rating of this module is very low. The hardware of the module comes with a integrated antenna and also its hardware contains edged pins. These edged pins gives us the ease that it becomes very easy to plug in or plug out the wires. and also if you are going to use it within a circuit then, it becomes very easy to connect the cable with module. Above was a little introduction about Bluetooth module and its features. now lets move to the basic theme of our project, which is to do interfacing between arduino and HC-05.
Note:
- If you have HC-06 or any other module in HC series then you don't need to get worried as they all work quite same. So you can also follow this tutorial for other HC series bluetooth modules.
Pin Configuration of HC-05
HC-05 Bluetooth module has total 6 pins. A simple HC-05 Bluetooth module is shown in the image given below and you can also see its pin configuration from this image. The pin configuration and the purpose of each pin is listed below as:
- They pin#1 is abbreviated a KEY pin. The function of this key is to show paired devices. In HC-05 module this pin is used to perform the module in AT mode.
- Pin#2 of HC-05 module is named as VCC pin. This module requires 3.3 volts to operate. If you will connect it directly with 5 volts then, this module will burn out.
- Pin#3 of this module is named as GND. At this pin the common ground of the circuit is provided.
- pin#4 is named as TXD. This pin is used when you have to transmit data to some external device. Asynchronous data transfer is performed by this module.
- pin#5 is named as RXD. This pin is used when the module have to receive wireless data from some external source. Asynchronous data is received through this module.
- The last pin of the module which is in fact pin#6 of the module and it is named as STATUS pin. The basic function of this pin is to check the status of the Bluetooth module. If the module is connected to some other device then, output of the system becomes HIGH and if the connection of Bluetooth drops then, this module generates a output pulse.
Interfacing with Arduino
So, now let's start with interfacing Arduino with HC05 bluetooth module. Its quite easy to interface as it works on Serial protocol. As mentioned above it has two pins named as TX and RX through which we can send or receive the data. Moreover, it works exactly the same as any mobile's bluetooth, you can connect your mobile with any device and can share data between these devices, similarly you can share the data with this device as well.
- First of all, connect your HC05 bluetooth module with Arduino as shown in the below figure.
- In the above figure, the connections are quite easy , we have provided power to the bluetooth module from Arduino and also connected TX pin of bluetooth module with RX pin of Arduino and RX pin of bluetooth module with TX of Arduino.
- Now we are done with the connections so next part is to upload the code into Arduino.
Code for interfacing HC-05 with Arduino
Now upload the below code into your Arduino and you are ready to get the first data from your Bluetooth module.
Applications of HC-05 Module
- The biggest application is that it is used to transmit or receive data wirelessly.
- You can play your favorite sound tracks through bluetooth in your car using this module.
- The modern Android phones contains a wireless GPS option. IN fact this module is being used in that phones and it works to seek the bluetooth location.
- This module makes you able to chat with some android phone using Bluetooth.
Alright friends, that all for today. If you have any question, fell free to ask. Till next tutorial Take Care!!! :)
Analog Vibration Sensor Library for Proteus
Hi Guys! Glad to see you here. I welcome you on board. In this post today, I’ll be discussing Analog Vibration Sensor Library for Proteus. I have already shared the digital
Vibration Sensor Library for Proteus, you should check that as well.
I’ve been adding brand new libraries for proteus covering sensors and Arduino boards. I’ve recently discussed
Analog PIR Sensor Library for Proteus and
Analog Flex Sensor Library for Proteus. You may be stuck into thinking I’ve previously shared those libraries but they were libraries covering digital PIR and digital Flex sensors, here we discussed
analog libraries for both PIR and Flex sensors.
Before I pen down how to download and simulate Analog Vibration Sensor Library for Proteus, let’s discuss what is vibration sensor first.
A vibration sensor is mainly used to monitor the vibration of industrial machines. It is also called a piezoelectric that plays a crucial role in the proper working of industrial machinery. If vibration values increase from the industry standards, they can severely affect the overall working of the machine and in the worst case can put the machine at a grinding halt.
To avoid this, we use vibration sensors that give the warning signal if vibration exceeds the desired values. These sensors are attached to the alarm system that produces audible sound indicating the machine is in danger, thus results in the deactivation of the entire machine.
Vibration sensors are based on the piezoelectric effect to observe the small changes in pressure, acceleration, force, and temperature. These changes are converted into an electrical signal. Air fragrance can also be monitored by vibration sensors. They monitor the air fragrance and detect its capacitance and quality.
I hope you’ve got a clear idea about the vibration sensor now we’ll download and run the Analog Vibration Library for Proteus. I’ve added both a simple simulation of the vibration sensor and a simulation with the Arduino Board.
Let’s get started.
Analog Vibration Sensor Library for Proteus
- Click the link given below to download the Analog Vibration Sensor Library for Proteus.
- As you download this file, it returns further two files named Proteus Library and Proteus Simulations.
Analog Vibration Sensor Library for Proteus
Click the Proteus Library folder that contains four files as follow:
- VibrationSensorAnalogTEP.HEX
- VibrationSensorTEP.HEX
- VibrationSensorTEP.IDX
- VibrationSensorTEP
Now copy all files given above and place them into the library folder of your Proteus software.
- In case you don’t have proteus software in your system, you can read this post covering how to download and install proteus software.
- After adding the above files, start the proteus software and if it’s already running, close the software and restart again.
- Now click the ‘P’ button to search for the ‘analog vibration sensor’ libraries that you’ve recently placed.
- As you search it, it will return the figure as given below:
- Select the sensor and click OK. Now you’ll see your cursor has now started blinking with the sensor that shows you can place your analog vibration sensor anywhere in the workspace available on the proteus software.
- As you place your sensor, it will show the figure below:
Now we'll look into the analog vibration sensor pinout.
Vibration Sensor Pinout
The vibration analog sensor contains 4 pins as follows.
- OUT = First is an OUT pin that is connected with a voltmeter that represents the output voltage against the variable resistor attached to the TestPin.
- GND = Second is a ground pin that is attached to ground voltage.
- Vcc = Third is the voltage supply pin that gets 5V to power the vibration sensor.
- TestPin = Forth is the TestPin. This pin is only available in the proteus simulation. You don’t find it on the analog vibration sensor in real. When this pin is LOW, it shows no vibration and when this pin is HIGH it represents the vibration on the machine.
Adding HEX File
Now we’ll add the HEX file to run our vibration sensor simulation. Right-click the sensor and reach the ‘edit properties’ option and double-click the sensor it will pop up the same edit properties panel.
Browse the Sensor’s HEX file option and look for the HEX file.
You can find the HEX file in the library folder. Same HEX file that we have recently placed in the library folder.
Select this HEX file and click OK. Now we’ll attach a simple circuit with the vibration sensor to run our simulation.
LC Circuit
- We need to design a simple circuit to run this sensor in the proteus workspace. We’ve designed and attached the LC circuit with the OUT pin of the vibration sensor.
- And TestPin is connected with a variable resistor. Both variable resistance and voltage we get on the voltmeter attached with the OUT pin are inversely proportional to each other.
- When variable resistance is set to the maximum value the voltage on the voltmeter will be zero and when variable resistance is set to the minimum value (zero) it shows the maximum voltage i.e. 4.98V on the voltmeter.
When you run the simulation it will return the result below:
- You can see the voltage appearing on the left vibration sensor placed on the proteus workspace is 2.56V because TestPin attached with the variable resistor is set to almost half of the resistance value.
- I told you earlier I’ll show you both simple simulation and the vibration sensor simulation with the Arduino Board. If you are interested in the Arduino Library for Proteus, check this post where I have added six Arduino Boards Libraries for Proteus.
Now connect the voltage on the OUT pin with the analog pin i.e. A0 of the Arduino Board:
When variable resistance is maximum the voltage on the voltmeter will be zero and its equivalent analog value across LCD attached with the Arduino Board will be 0019 and when the resistance on the variable resistor is minimum the voltage will be 4.98V and its equivalent analog value on the LCD will be 1019.
This is it. I hope, you’ve got a clear insight into how to download Analog Vibration Sensor Library for Proteus. If you have any questions, you can ask me in the comment section below. I’d love to help you with the best of my expertise. Feel free to pop your suggestions about the libraries you think should be included in the proteus library database, I’ll design and add them to the database. Thank you for reading this article.
Analog Flex Sensor Library for Proteus
Hi Friends! Happy to see you here. Thank you for viewing this read. Hope you’re well today. In this post, I’m going to discuss the Analog Flex Sensor Library for Proteus. You should also have a look at Digital
Flex Sensor Library for Proteus.
I’ve been adding them over the last few days intending to design and share brand new libraries that are not a part of the proteus library database already. I’m adding both simple simulation and simulation with the Arduino board to help you better understand these libraries with microcontrollers and Arduino devices.
Before I go further and walk you through on how to download and simulate Analog Flex Sensor Library for Proteus, let’s get to know what’s Flex sensor first.
Simply put, a flex sensor is used to monitor the value of bend. It is also known as a bend sensor that is mainly used in robot whisker sensors, door sensors, stuffed animal toys, and Nintendo power glove. The flex sensor is coupled with the exterior where the rotation of this exterior is directly related to the change in the sensor resistance.
Carbon or plastic material is used for the construction of these sensors where deflection value is sensitive to varying resistance. In terms of varying resistance and size, these sensors are categorized into two main types i.e. 4.5-inch bend sensor and 2.2-inch bend sensor.
I hope you’ve got a brief insight into what is flex sensor and why it is used for. You can also sneak into the
Analog PIR Sensor Library for Proteus that I’ve shared previously.
And if you don’t have proteus software installed in your system, check this post on
how to download and install proteus software.
Without further ado, let’s jump right into the Analog Flex Sensor Library for Proteus.
Continue reading.
Analog Flex Sensor Library for Proteus
First of all, click the link given below to download the analog flex library for proteus.
Analog Flex Sensor Library for Proteus
As you download this file, it contains two folders named Proteus Library and Proteus Simulation.
Click the Proteus Library, it will open up four files that read:
- FlexSensorAnalogTEP.HEX
- FlexSensorTEP.HEX
- FlexSensorTEP.IDX
- FlexSensorTEP
Copy and place these four files into the proteus library folder.
Now, click the ‘P’ button as below and write ‘Flex sensor analog’ in the search bar.
As you do this, it will return the file as mentioned below.
- Select this file and click “OK” As you click OK, your cursor will start blinking with the flex sensor, indicating you can place this sensor anywhere you want on the proteus workspace.
When you place this sensor on the proteus workspace, it will appear as follows:
This is how flex sensor appears on proteus workspace.
Flex Sensor Pinout
Flex sensor contains four pins as follow:
- G = first is the ground pin that you’ll connect to the ground voltage.
- O = second is the OUT pin that gives the Flex sensor value demonstrating if the sensor has identified the value of bend.
- V = third is the voltage supply pin that receives 5V to power the sensor.
- TestPin = forth is TestPin that we require in Proteus simulation only. This pin is not included in the sensor in real. We need to add this pin for identifying the value of bend. When this Pin is HIGH it gives the value of bend and when it turns LOW it gives no value of bend.
Adding HEX File
Now we’ll add the HEX file in the Flex sensor to run our simulation. You can find FlexSensorAnalogTEP.HEX file in the library folder of your Proteus library folder. Recall, we’ve already placed this file in the library folder of proteus.
- To add this file, right-click on the sensor and look for ‘edit properties.’
- You can also double click the flex sensor to reach the ‘edit properties’ panel.
Now search for the HEX file that you have placed in the proteus library folder.
Add this file and click ‘OK’ … Before you run this simulation we need to design and connect the LC circuit with the Flex sensor. We’ll add this circuit purposely. Why? You’ll get to know later in this post.
Connect the Output ‘O’ pin with the LC circuit through voltmeter where we get the output voltage following the variable resistor attached with the test pin.
- Both output voltage across voltmeter and variable resistance are inversely proportional to each other. When resistance is maximum, the voltage on the voltmeter is zero, thus indicating no amount of bend.
And when resistance is zero the voltage appearing across a voltmeter will be 4.98V, confirming the value of bend as an output voltage on the flex sensor.
You may be wondering why we add this LC circuit with the flex sensor? We need to include this circuit because proteus gives a peak to peak value that we have to convert into the Vrms value. That LC circuit serves this purpose.
You’ve done it. You have designed a simple simulation of a flex sensor library for proteus. We have added this library the very first time, as you won’t find this library in the proteus library database before. I’ve mentioned at the start of the article, I’ll share both simple simulation and simulation with Arduino Board.
Analog Flex Sensor With Arduino UNO
Now we attach the Arduino board with the flex sensor. To do this, we connect the voltage appearing across the voltmeter with the analog input pin of the Arduino board.
As you run this simulation it will return the result below.
Again, when resistance is maximum, the voltage is zero, that gives equivalent analog value on the LCD connected with the Arduino board, that value is 0019. And when resistance is zero, the voltage will be 4.98V and its equivalent analog value on the LCD will appear 1019.
That’s all for today. Hope you find this read helpful. If you face any difficulty in the simulation of Analog Flex Library for Proteus, you can leave your query in the section below, I’ll help you the best way I can. Feel free to leave your suggestions of the libraries that are not available in the proteus library database, I’ll design and share respective libraries with both simple simulation and simulation with Arduino boards. Thank you for reading this post.
Soil Moisture Sensor Library For Proteus
Update: We have created a new version of this library, which you can check here:
Soil Moisture Sensor Library for Proteus V2.0.
Hi Friends! Hope you’re well today. I welcome you on board. In this tutorial, I’ll be discussing the Soil Moisture Sensor Library for Proteus. You won't find Soil Moisture Sensor Library in Proteus and we’re going to share its Proteus Library very first time. I have previously shared many Proteus Libraries for digital and analog sensors and today I’m discussing something new. Excited to get a hold of the Soil Moisture Sensor Library? Me too. In the upcoming days, I’ll keep sharing different libraries related to sensors. If you’re curious to sneak into the nitty-gritty of sensors not available in the Proteus library already, pop your suggestion in the comment section below. I’ll try my best to comply with your suggestions and walk you through something brand new.
Soil moisture sensors are used to measure the water content in the soil. They use capacitance to measure the dielectric permittivity of the soil which defines the function of the water content. Before further ado, let’s dive in and have a look at How to download and simulate Soil Moisture Sensor Library for Proteus:
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | LCD 20x4 | Amazon | Buy Now |
2 | Arduino Uno | Amazon | Buy Now |
Soil Moisture Sensor Library For Proteus
- You can download the Proteus Library zip file of Soil Moisture Sensor Library by clicking the button below.
Download Proteus Library Files
- It’s a .zip file that contains two folders inside i.e. Proteus Library & Proteus Simulations.
- The real fun starts right here right away.
- Open proteus library folder that contains three files named:
- SoilMoistureSensorTEP.IDX
- SoilMoistureSensorTEP.LIB
- SoilMoistureSensorTEP.HEX
- Copy and paste these three files in the Library folder of your Proteus software:
- Now, we need to run the Proteus ISIS software and don't forget to restart, if it's already open.
- Look for the Soil Moisture in the component’s search box as shown below.
- After installing the Library successfully, you’ll get similar results as below:
- You can see in the figure above we have one Soil Moisture Sensor.
- Now simply place this Soil Moisture Sensor in your Proteus workspace, as mentioned below:
- You can see in the figure above, I have placed one Soil Moisture Sensor inside the Proteus workspace.
- This sensor carries 4 pins in total, named:
- V (Vcc): We’ll provide +5V here.
- G (GND): We’ll provide ground here.
- Ao (Out): It’s an analog output signal from the sensor.
- TestPin: It is used for simulation purposes only. Soil Moisture Sensor doesn’t contain this pin in real.
Adding Sensor’s Hex File
- After this drill, we’ll add the Sensor’s Hex File, which we have downloaded and placed in the Library folder.
- To do that, right-click on your Soil Moisture Sensor and then click on “Edit Properties” as below:
- Or you can double click the Soil Moisture Sensor, it will pop the window below:
- Click on the Browse button and add SoilMoistureSensorTEP.HEX file available in the Proteus Library section as shown in the figure below:
- After adding the Sensor’s Hex File, click on the ‘OK’ button to close the ‘Edit Properties’ Panel.
- Our Soil Moisture Sensor is now ready to simulate in our Proteus ISIS.
- We’ll design a small circuit to thoroughly understand the working of this Soil Moisture Sensor.
Proteus Simulation of Soil Moisture Sensor
- Here, I’m designing a simple circuit. I’ve attached a variable resistor with the Test Pin & added a Voltmeter at the Output pin, as shown in the figure below:
- This resister defines the soil water content in the proteus simulation.
- When the resistance is maximum at the test pin, the circuit shows zero volts across the voltmeter, which means the sensor is either in the dry ground or taken out of the ground i.e. giving zero moisture value of the water content.
- And when resistance is zero, the circuit will show the maximum voltage across the voltmeter which indicates the sensor is inserted in a wet ground i.e. water contents in the soil are too high.
- This is important. We have attached the output pin with an LC filter. This filter is not required in real hardware implementation.
- We are using it in Proteus Simulation only as Proteus gives the peak-to-peak value and we have to convert that PP value into Vrms.
- If you are working on a real sensor then you don’t need to add this LC circuit.
- Now, let’s run this Proteus Simulation and if you have done everything as mentioned, it will show the result mentioned in the figure above.
Simulation of Soil Moisture Sensor with Arduino
Now, let's interface this sensor with a
microcontroller.
- We have attached the output of the sensor appearing across the voltmeter with the A0 pin of the microcontroller as below.
You can see we get the analog value 1019 when the voltage across the voltmeter is 4.98V
This is it. I hope you find this tutorial helpful. This will help engineering students in simulating their semester projects in proteus. In the next tutorials, I’ll be sharing and adding more libraries of sensors. You’re most welcome to share your suggestions with the sensors you want me to libraries of. If you’re unsure or have any questions, you can ask me in the section below. I’ll help the best way I can. Thank you for reading this article.
IR Proximity Sensor Library for Proteus
Hello friends, I hope you all are doing great. In today's tutorial, I am going to share a new
IR Proximity Sensor Library for Proteus. Proximity Sensors are not available in Proteus and we are sharing its Proteus library for the first time. So far, I have only shared Proteus Libraries of digital sensors but today I am sharing an analog sensor, so too excited about it.
In the next few days, I will keep on sharing Proteus Libraries of different analog sensors, so if you want any sensor in Proteus, then let me know in the comments. IR Proximity Sensors are used to detect hurdles/obstacles placed in their path. They are normally used on robots for path navigation and obstacle avoidance. So, let's have a look at How to download and simulate IR Proximity Sensor Library for Proteus:
Note:
- You should also have a look at:
IR Proximity Sensor Library for Proteus
- First of all, download this IR Proximity Sensor Library for Proteus, by clicking the below button:
IR Proximity Sensor Library for Proteus
- It's a .zip file, which will have two folders in it i.e. Proteus Library & Proteus Simulation.
- Open Proteus Library Folder, it will have 3 files, named as:
- IRProximitySensorTEP.IDX
- IRProximitySensorTEP.LIB
- IRProximitySensorTEP.HEX
- Place these three files in the Library folder of your Proteus software.
Note:
- After adding these library files, open your Proteus ISIS software, or restart it if it's already open.
- In the component's search box, make a search for IR Proximity.
- If you have installed the Library successfully, then you will get similar results, as shown in the below figure:
- As you can see in the above figure that we have two IR Proximity sensors.
- When it comes to functionality, both sensors are exactly the same, they just have different colors.
- Now simply place these IR Proximity Sensors in your Proteus workspace, as shown in the below figure:
- As you can see in the above figure, I have placed both of these IR Proximity sensors in my Proteus workspace.
- This sensor has 4 pins in total, which are:
- V ( Vcc ): We need to provide +5V here.
- G ( Gnd ): We need to provide Ground here.
- O ( Out ): It's an analog output signal from the sensor.
- TestPin: It's solely for simulation purposes, we don't have this pin in a real IR sensor.
- As we can't actually place an obstacle in front of this sensor in Proteus simulation, that's why I have used this TestPin.
- If we change the value of TestPin from 0V to 5V then that means the obstacle is coming close.
Adding Sensor's Hex File
- Lastly, we need to add the Sensor's Hex File, which we have downloaded and placed in the Library folder.
- So, in order to do that, right-click on your IR sensor and then click on Edit Properties.
- You can also open the Properties Panel by double-clicking on the sensor.
- Here, in the Properties Panel, you will find Sensor's Hex File Section.
- Click on the Browse button and add IRProximitySensorTEP.HEX file here, as shown in the below figure:
- After adding the Sensor's Hex File, click on the OK button to close the Properties Panel.
- Our IR Proximity Sensor is now ready to simulate in Proteus ISIS.
- Let's design a small circuit, in order to understand the working of this IR Proximity Sensor.
Proteus Simulation of IR Proximity Sensor
- First of all, let's design a simple circuit, where I am attaching a variable resistor with the Test Pin & I am adding a Voltmeter at the Output pin, as shown in the below figure:
- Using this variable resistance, we can change the voltage on Test Pin.
- If TestPin has 0V, means we don't have any obstacle in front of the sensor.
- If TestPin has 5V, implies that something's placed right in front of the sensor.
- So, let's have a look at How the output value will change when we change the voltage on TestPin.
- At the Output Pin, I have placed an LC filter, which is also not required in real hardware implementation.
- But I have to use this filter in Proteus Simulation, as Proteus provides the Peak to Peak value and we need to convert that value into Vrms.
- So, if you are working on a real sensor then you don't need to add this inductor or capacitor.
- Now, let's run this Proteus Simulation and if you have done everything correctly, then you will get similar results:
- I have shown three different scenarios in the above figure:
- In the first image, the variable resistor is at 100%, thus providing 0V at TestPin. That's why we got 0V at Output and hence no obstacle detected.
- In the second image, the variable resistor is around 50%, thus providing around 2.5V at TestPin. So, we are getting around 2.5V at Output and hence obstacle detected in close range.
- In the third image, the variable resistor is around 0%, thus providing around 5V at TestPin. So, we are getting around 5V at Output and hence obstacle's just in front of the sensor.
- I have placed this simulation in the above zip file, so play with it and don't forget to add the Sensor's Hex File.
So, that was all for today. I hope this IR Proximity Sensor Library will help engineering students in simulating their course projects. I will interface this IR sensor with Arduino and other Microcontrollers and will share their simulations. If you have any issues, then ask in the comments and I will help you out.
PC817 Library for Proteus
Hello friends, I hope you all are doing great. In today's tutorial, I am going to share a new
PC817 Library for Proteus. PC817 is an optocoupler / optoisolator, which is used for electrical isolation between components or modules. It's normally used after Microcontroller Pins so that back emf doesn't burn them. You should also have a look at
Introduction to PC817, I have shared its complete details there.
PC817 is used a lot in Embedded projects but is not available in Proteus, so our team has designed it for the first time. Using this Library, now you can easily simulate this optocoupler in your Proteus simulations. So, let's get started with How to download & install PC817 Library for Proteus:
PC817 Library for Proteus
- First of all, download this PC817 Library for Proteus by clicking the below button:
[dt_default_button link="https://www.theengineeringprojects.com/ArduinoProjects/PC817 Library for Proteus.zip" button_alignment="default" animation="fadeIn" size="medium" default_btn_bg_color="" bg_hover_color="" text_color="" text_hover_color="" icon="fa fa-chevron-circle-right" icon_align="left"]Download Proteus Library[/dt_default_button]
- It's a zip file, which will have a Proteus Library folder.
- Open this folder, and you will find these 2 Library files in it:
- OptocouplersTEP.IDX
- OptocouplersTEP.LIB
- Place these Library Files in the Library folder of your Proteus software.
Note:
- Now open your Proteus ISIS software or restart it if its already open.
- In the components search box, make a search for PC817.
- If everything goes fine, then you will get results as shown in below figure:
- Now place this PC817 in your workspace.
- Default optocoupler available in Proteus contains 5 Pins but this PC817 has 4 Pins, as shown in below figure:
- I have shown both optocouplers in above figure.
- Now let's design a simple circuit to have a look at How it works:
- So, connect three LogicState and one LED with PC817, as shown in below figure:
- Now run your Proteus Simulation and change the states of your buttons.
- Both On & Off states of PC817 are shown in below figure:
- So, that's How you can easily simulate PC817 in Proteus.
I hope this PC817 Library will help you in your Engineering Projects. If you got into any trouble, then ask in comments and we will help you out. Thanks for reading, take care and have fun !!! :)
Interfacing of Arduino with 74HC595 & 74HC165
Hello friends, I hope you all are doing great. In today's tutorial, I am going to show you How to Interface Arduino with 74HC595 & 74HC165. I have already interfaced these shift registers separately with Arduino. In the first tutorial we have seen
Arduino 74HC595 Interfacing in which I have discussed How to increase the output pins of Arduino using 74HC595. After that in second tutorial we have seen
Arduino 74HC165 Interfacing where we have increased the input pins of Arduino.
So, now we are gonna interface both of these shift registers with
Arduino UNO and will increase both input and output pins of Arduino. I have also given the Proteus simulations for download at the end of this tutorial along with Arduino code. So, lets get started with Interfacing of Arduino with
74HC595 & 74HC165:
Interfacing of Arduino with 74HC595 & 74HC165
- As you can see in above figure, I have used 74HC165 & 74HC595 and interfaced its pins with Arduino UNO.
- I could use same clock for these shift registers but it would have made the code quite complex.
- That's why I have used separate clock pins and I have used the below code to reflect the input on output.
#define NUMBER_OF_SHIFT_CHIPS 1
#define DATA_WIDTH NUMBER_OF_SHIFT_CHIPS * 8
#define TotalIC 2
#define TotalICPins TotalIC * 8
int LoadPin = 8;
int EnablePin = 9;
int DataPin = 11;
int ClockPin = 12;
int RCLK = 5;
int SER = 6;
int SRCLK = 7;
unsigned long pinValues;
unsigned long oldPinValues;
boolean Data[TotalICPins];
void setup()
{
Serial.begin(9600);
pinMode(LoadPin, OUTPUT);
pinMode(EnablePin, OUTPUT);
pinMode(ClockPin, OUTPUT);
pinMode(DataPin, INPUT);
digitalWrite(ClockPin, LOW);
digitalWrite(LoadPin, HIGH);
Serial.println("Visit us at www.TheEngineeringProjects.com");
Serial.println();
pinMode(SER, OUTPUT);
pinMode(RCLK, OUTPUT);
pinMode(SRCLK, OUTPUT);
ClearBuffer();
pinValues = read_shift_regs();
print_byte();
oldPinValues = pinValues;
}
void loop()
{
pinValues = read_shift_regs();
if(pinValues != oldPinValues)
{
print_byte();
oldPinValues = pinValues;
}
}
unsigned long read_shift_regs()
{
long bitVal;
unsigned long bytesVal = 0;
digitalWrite(EnablePin, HIGH);
digitalWrite(LoadPin, LOW);
delayMicroseconds(5);
digitalWrite(LoadPin, HIGH);
digitalWrite(EnablePin, LOW);
for(int i = 0; i < DATA_WIDTH; i++)
{
bitVal = digitalRead(DataPin);
bytesVal |= (bitVal << ((DATA_WIDTH-1) - i));
digitalWrite(ClockPin, HIGH);
delayMicroseconds(5);
digitalWrite(ClockPin, LOW);
}
return(bytesVal);
}
void print_byte() {
byte i;
Serial.println("*Shift Register Values:*\r\n");
for(byte i=0; i<=DATA_WIDTH-1; i++)
{
Serial.print("P");
Serial.print(i+1);
Serial.print(" ");
}
Serial.println();
for(byte i=0; i<=DATA_WIDTH-1; i++)
{
Serial.print(pinValues >> i & 1, BIN);
Data[i] = pinValues >> i & 1, BIN;
//if(BinaryValue == 1){Data[i] = HIGH;}
//if(BinaryValue == 0){Data[i] = LOW;}
UpdateData();
if(i>8){Serial.print(" ");}
Serial.print(" ");
}
Serial.print("\n");
Serial.println();Serial.println();
}
void ClearBuffer()
{
for(int i = TotalICPins - 1; i >= 0; i--)
{
Data[i] = LOW;
}
UpdateData();
}
void UpdateData()
{
digitalWrite(RCLK, LOW);
for(int i = TotalICPins - 1; i >= 0; i--)
{
digitalWrite(SRCLK, LOW);
digitalWrite(SER, Data[i]);
digitalWrite(SRCLK, HIGH);
}
digitalWrite(RCLK, HIGH);
}
- In the above code, I have used Number_of_Shift_Chips 1 and it means I am using 1 chip each, so in total 2 chips.
- Now get hex file from Arduino software and upload it in your Proteus software.
- Run your simulation and if everything goes fine then you will get something as shown in below figure:
- You can see in above figure that all those LED outputs are ON which has HIGH inputs.
- I have also attached a Virtual Terminal with Arduino to have a look at the input bits.
- Now let's add 2 chips of 74HC165 and 74HC959, so design a simple simulation as shown in below figure:
- Now in your above code change the Number of Shift chips from 1 to 2, as now we are using 2 chips each.
- Upload your hex file and if everything goes fine then you will get similar results:
- So, that's how you can easily increase input and output pins of Arduino UNO.
- I have just designed a simple code but you can work on it and can control these inputs separately as well.
- You can interface different digital sensors on these input pins and can control motors, relays, solenoids etc. at output pins.
- You can download both of these Proteus Simulations along with Arduino code by clicking the below button, but I would suggest you to dwsign it on yoru own so that you could learn from mistakes.
[dt_default_button link="https://theengineeringprojects.com/ArduinoProjects/Interfacing%20of%20Arduino%20with%2074HC595%20&%2074HC165.zip" button_alignment="default" animation="fadeIn" size="medium" default_btn_bg_color="" bg_hover_color="" text_color="" text_hover_color="" icon="fa fa-chevron-circle-right" icon_align="left"]Download Proteus Simulation & Arduino Code [/dt_default_button]
So, that was all about Interfacing of Arduino with 74HC595 & 74HC165. I hope you can now easily simulate it. If you have any questions then ask in comments and I will try my best to resolve them. Thanks for reading. Take care !!! :)
How to use analogWrite in Arduino?
Hey Fellas! Hope you are getting along with life pretty well. This post is another addition in this
Arduino Tutorial for Beginners series. Today, I'll discuss
How to use analogWrite in Arduino? The analogWrite is mainly used to update the status of analog pins and is also used to map the analog values on the
PWM (Pulse Width Modulation) pins.
You can check the article that I have posted previously on
How to use analogRead in the Arduino - this command addresses the analog pins on the board and reads its status, while today's one does the exact opposite.
In this post, I'll try to break down each and everything related to analogWrite in simple steps, so you can grab the main idea pretty well. Let's jump right in.
How to use analogWrite in Arduino?
- The analogWrite Arduino command is used to update the status of analog pins and also used to address the PWM pins on the board.
- The PWM pins are 8-bit pins, terming that you can set the duty cycle somewhere between 0 -255.
- The duty cycle is described as the amount time the signal switches between ON and OFF condition. It is mainly written in percentage.
- If the signal remains turned ON half of the total duty cycle and OFF in another half, then the duty cycle will be 50%.
- The analogWrite comes handy when you plan to control the motor speed or the intensity of any LED.
- The value you write on the PWM pins will control the speed.
- For example, if you intend to run the motor at full speed, you will set the value 255 i.e. the maximum value it can handle that will ultimately run the motor at full speed.
- Similarly, setting value as "0" will be sending no signal and motor won't start.
- And if the motor requires to be run at half speed, then you will set the value 127 or 128 - half of the maximum value that will cause the motor to be running at half speed.
- Arduino Uno comes with PWM pins available on digital pin number 3,5,6 and 9,10,11. You can put any number, out of these pins.
- Now let's have a look at How to use analogWrite Arduino command:
Syntax
analogWrite(int pin, int value);
where:
- "pin" is the pin number you are targeting.
- "value" is the duty cycle that can be set anywhere between 0 to 255 where former indicates the OFF condition and later indicates the system is running at full speed.
Example
analogWrite(10, 175);
Note: The analogWrite command doesn't return or store any value, unlike analogRead that returns value anywhere between 0 to 1023 depending on the voltage it gets in return from the connected sensor or device.
The
Arduino IDE is an official software used to program the Arduino Boards. It is an open source software, giving you the flexibility to program the Arduino Board as per your technical needs and requirements. It is free of cost and help is readily available on the Arduino site in case you feel any difficulty in shaping the desired code on the board.
That’s all for now. I'll be writing more articles on how to code Arduino. If you are feeling skeptical about anything, making it difficult for you to grab the basic idea, you can approach me in the comment section below. I’d love to help you the best way I can. In the coming tutorial, we will have a look at
How to use Arduino PWM Pins. Thanks for reading the article.
Arduino 74HC165 Interfacing: Increase Input Pins
Hello friends, I hope you all are doing great. In today's tutorial, I am going to do an
Arduino 74HC165 Interfacing and we will have a look at How to increase Input Pins of Arduino. 74HC165 is a shift register and works on the principal of Parallel In Serial Out. In my previous tutorial
Arduino 74HC595 Interfacing: Increase Output Pins, we have seen How to increase the output pins of Arduino and today we are gonna do exact the opposite and we will increase the input pins.
74HC165 will take 8 parallel inputs from different sensors or buttons etc and will send them to serial OUT Pin, which will be connected to
Arduino. So, if you are working on a project where you want to get data of 15 or 20 digital sensors then you can use this shift register and just using a single pin of Arduino you can read data of all those sensors. We can only get digital inputs, we can't get analog input through this shift register. So, let's get started with Arduino 74HC165 Interfacing:
Arduino 74HC165 Interfacing
- I will design a Proteus Simulation of Arduino 74HC165 Interfacing, I have given the files for download at the end of this tutorial, but I would recommend you to design it so that you could learn.
- I will connect simple Logic buttons with this shift register and will read their status on the Serial Port.
- So, first of all design a simple Proteus Simulation as shown in below figure.
- I have used Arduino UNO and have connected Virtual Terminal so that we could have a look at Serial data.
- As you can see in the above figure that I have connected four pins between Arduino and 74HC165, which are:
- Pin # 8 of Arduino ==> Shift (SH) of shift register.
- Pin # 9 of Arduino ==> Clock Enable (CE) of shift register.
- Pin # 11 of Arduino ==> Serial OUT (SO) of shift register.
- Pin # 12 of Arduino ==> Clock (CLK) of shift register.
- Now open you Arduino software and copy paste the below code in it:
#define NUMBER_OF_SHIFT_CHIPS 1
#define DATA_WIDTH NUMBER_OF_SHIFT_CHIPS * 8
int LoadPin = 8;
int EnablePin = 9;
int DataPin = 11;
int ClockPin = 12;
unsigned long pinValues;
unsigned long oldPinValues;
void setup()
{
Serial.begin(9600);
pinMode(LoadPin, OUTPUT);
pinMode(EnablePin, OUTPUT);
pinMode(ClockPin, OUTPUT);
pinMode(DataPin, INPUT);
digitalWrite(ClockPin, LOW);
digitalWrite(LoadPin, HIGH);
pinValues = read_shift_regs();
print_byte();
oldPinValues = pinValues;
}
void loop()
{
pinValues = read_shift_regs();
if(pinValues != oldPinValues)
{
print_byte();
oldPinValues = pinValues;
}
}
unsigned long read_shift_regs()
{
long bitVal;
unsigned long bytesVal = 0;
digitalWrite(EnablePin, HIGH);
digitalWrite(LoadPin, LOW);
delayMicroseconds(5);
digitalWrite(LoadPin, HIGH);
digitalWrite(EnablePin, LOW);
for(int i = 0; i < DATA_WIDTH; i++)
{
bitVal = digitalRead(DataPin);
bytesVal |= (bitVal << ((DATA_WIDTH-1) - i));
digitalWrite(ClockPin, HIGH);
delayMicroseconds(5);
digitalWrite(ClockPin, LOW);
}
return(bytesVal);
}
void print_byte() {
byte i;
Serial.println("*Shift Register Values:*\r\n");
for(byte i=0; i<=DATA_WIDTH-1; i++)
{
Serial.print("P");
Serial.print(i+1);
Serial.print(" ");
}
Serial.println();
for(byte i=0; i<=DATA_WIDTH-1; i++)
{
Serial.print(pinValues >> i & 1, BIN);
if(i>8){Serial.print(" ");}
Serial.print(" ");
}
Serial.print("\n");
Serial.println();Serial.println();
}
- The code is quite simple but let me give you a quick explanation of it.
- First of all, I have assigned names to all 4 pins of 74HC165 connected with Arduino.
- Function read_shift_regs() is used to read the eight input pins of 74HC165 and print_byte() function is used to display that data on Serial Monitor.
- So get your hex file from Arduino software and upload it in Proteus software.
- Run your Proteus simulation and if everything goes fine then you will get results as shown in below figure:
- If you change any input of your shift register then you will get the new value on your Virtual Terminal.
- Now let's add another 74HC165 and increase our input pins by 16.
- So, design a simple circuit as shown in below figure:
- Now, in the above code, simply change the first line and make #define NUMBER_OF_SHIFT_CHIPS 2.
- Simply changes 1 to 2, as we are using 2 shift registers now.
- Now get your hex file and run the Proteus simulation.
- Here's the output of our 16 increased inputs:
- That's how you can easily interface multiple 74HC165 chips with your Arduino board and can increase the input options.
- You can download these Proteus simulations and code for Arduino 74HC165 Interfacing by clicking the below button:
[dt_default_button link="https://www.theengineeringprojects.com/ArduinoProjects/Arduino 74HC165 Interfacing.rar" button_alignment="default" animation="fadeIn" size="medium" default_btn_bg_color="" bg_hover_color="" text_color="" text_hover_color="" icon="fa fa-chevron-circle-right" icon_align="left"]Download Proteus Simulation & Code[/dt_default_button]
- You should also have a look at this video in which I have shown How to run these simulations:
So, that was all for today. In my coming tutorial, I will interface both 74HC165 and
74HC595 with Arduino UNO and will show you How to increase both input and output pins at the same time. Thanks for reading. Take care!!! :)
Arduino 74HC595 Interfacing: Increase Output Pins
Hello friends, I hope you all are doing great. In today's tutorial, I am going to show you
Arduino 74HC595 Interfacing and we will have a loook at How to
Increase Arduino Output Pins with 74HC595. Suppose you are working on some project where you need to control 20 LEDs with
Arduino UNO and you know we will 12 digital Pins so we can't control all of these 20 LEDs with Arduino UNO. We can use Arduino Mega as well but if we wanna stick to Arduino UNO then we need to increase its Output Pins and we will use 74HC595 for that purpose.
You should read this basic
Introduction to 74HC595, it will help you to better understand this shift register. It's a Serial In Parallel Out Shift register and we will give it value serially from single Pin of Arduino and it will output that data to 8 output pins. Moreover, we can also connect these registers in parallel to increase the output pins even further. So, let's have a look at Arduino 74HC595 Interfacing:
Arduino 74HC595 Interfacing
- As I told earlier 74HC595 is a serial In Parallel Out Shift Register and is used to increase the output pins of Arduino.
- I am gonna use Proteus software and we will design its simulation and then will check out How it works.
- So, design a simple circuit as shown in below figure:
- As you can see in above figure, I have done the following connections between Arduino and HC595:
- Pin # 5 of Arduino ==> ST_CP
- Pin # 6 of Arduino ==> DS
- Pin # 7 of Arduino ==> SH_CP
- All output pins of 74HC595 are connected to LEDs.
- Now upload the below Arduino code and get your hex file.
int RCLK = 5;
int SER = 6;
int SRCLK = 7;
#define TotalIC 1
#define TotalICPins TotalIC * 8
boolean Data[TotalICPins];
void setup()
{
pinMode(SER, OUTPUT);
pinMode(RCLK, OUTPUT);
pinMode(SRCLK, OUTPUT);
ClearBuffer();
}
void loop()
{
for(int i = TotalICPins - 1; i >= 0; i--)
{
Data[i] = HIGH;
UpdateData();
delay(300);
ClearBuffer();
}
for(int i = 1;i < TotalICPins - 1; i++)
{
Data[i] = HIGH;
UpdateData();
delay(300);
ClearBuffer();
}
}
void ClearBuffer()
{
for(int i = TotalICPins - 1; i >= 0; i--)
{
Data[i] = LOW;
}
UpdateData();
}
void UpdateData()
{
digitalWrite(RCLK, LOW);
for(int i = TotalICPins - 1; i >= 0; i--)
{
digitalWrite(SRCLK, LOW);
digitalWrite(SER, Data[i]);
digitalWrite(SRCLK, HIGH);
}
digitalWrite(RCLK, HIGH);
}
- The code is quite simple but let me explain it a bit.
- First of all we have given names to our 3 Pins connected to Arduino UNO.
- After that we have made all those 3 Pins as OUTPUT as we are gonna send the data.
- We are using single chip of 74HC595 that's why I have made it 1.
- In the UpdateData function, you can see we have to make RCLK Low and after that we have sent our data.
- But for sending each bit of Data we have to make SRCLK from LOW to High.
- SER is our Serial IN from Arduino to 74HC595.
- So, in loop section, I am simply sending HIGH from first Pin to Last and then from last Pin to first and we are getting below results:
- Now let's have a look at How to connect two 74HC595 chips in parallel to increase the output pins to 16.
- I have also given these Proteus simulations for download at the end of this tutorial but I would recommend you to design them on your own so that you got better understanding of this shift register.
Arduino 74HC595 Interfacing: 2 Chips in Parallel
- Now we are gonna place two shift registers in parallel and we will be able to control 16 outputs from single Arduino Pin.
- Although we are using 3 Arduino Pins but the data is sent through Pin # 6 of Arduino and Pin # 5 and 7 are CLK Pins.
- Now design a circuit as shown in below figure:
- Now in Arduino Code, you just need to change the TotalIC to 2 and as you have seen we have already multiplied it with 8 so now our for loop will move from 0 to 15.
- Pin # 5 and 7 will simply connected to same pins of second shift register but DS will be connected to Q7' of first shift register.
- Now get your hex file from Arduino software and if everything goes fine then you will get something as shown in below figure:
- Now let's make it a bit more complex by adding 4 shift registers in parallel.
- So, design a Proteus Simulation as shown in below figure:
- We have followed the same principal, Q7' of second chip is connected to DS to 3rd chip and goes on.
- I have placed these default Pins instead of connecting the wires, it works the same.
- If this image is not clear then open it in new tab and zoom out to check the connections.
- Now in your Arduino code, you need to change the TotalIC to 4, as now we are using four chips.
- Get your Hex File and run Proteus simulation and if everything goes fine then you will get similar results:
- So, that's How you can quite easily do the Arduino 74HC595 Interfacing and can increase Arduino outputs as much as you want.
- You can download these Proteus Simulations along with code by clicking the below button:
[dt_default_button link="https://www.theengineeringprojects.com/ArduinoProjects/Arduino 74HC595 Interfacing.rar" button_alignment="default" animation="fadeIn" size="medium" default_btn_bg_color="" bg_hover_color="" text_color="" text_hover_color="" icon="fa fa-chevron-circle-right" icon_align="left"]Download Proteus Simulation & Arduino Code[/dt_default_button]
- I have also designed this YouTube video to give you a better understanding of Arduino 74HC595 Interfacing:
So, that was all for today. I hope you have enjoyed this Arduino 74Hc595 Interfacing. If you have any questions, then ask in comments and I will try my best to resolve them. In my coming tutorial, I will show you How to increase the Arduino Input Pins. So stay tuned and have fun. :)