Flame Sensor Arduino Interfacing

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to provide a detailed discussion on Flame Sensor Arduino Interfacing. Flame sensor is an electronic device which is capable of sensing/detection of fire or a high temperature zone. It gives an indication through an LED attached at its top, just after sensing the fire. These type of sensors are usually used for short ranges. They are able to detect the fire up to 3 feet. Flame sensors is the most common device available in the market these days due to its good results and cost efficiency. You should also have a look at Flame Sensor Library for Proteus. Flame sensors are available in the market in two types one having three pins and the other having four pins respectively. Both of the sensors can be easily interfaced to any micro-controller. I am using four pin flame sensor in this tutorial. You will see the complete wiring diagram for interfacing flame sensor with Arduino and the complete Arduino source code and its description as well. Flame sensor can detect fire or any other light sources whose wavelength is in the range of 760nm to 1100nm. This device consists of and IR sensor, an LED for indication, operational amplifier circuit and a potentio-meter. The device is sensitive to flame so when it detects the flame it turns on its LED to show an indication. The sensitivity of the flame sensor can be adjusted according to the requirements. It can be used at different places e.g. in offices, home, institutions, industrial applications.

Flame Sensor Arduino Interfacing

Flame Sensor is an electronic device which is used to sense the fire or any other light having wavelength between 700nm to 1100nm. It consists of either three or four pins both of them are compatible with all micro-controllers. It is sensitive to flame and gives the indication for the presence of the flame. It can be sued in homes, offices, industrial applications. Flame sensor along with its pi names are shown in the figure below.
1. Flame Sensor Pins
  • Flame sensor has four pins with different individual function.
  • Flame sensor pins are given in the figure shown below.
2. Flame Sensor Pins Description
  • Each pin has different tasks to perform.
  • Flame sensor pin descriptions are listed in the table shown in the figure given below.
3. Flame Sensor Working Principle
  • Flame sensor is very sensitive to flame and other lights.
  • Its analog output provides real time output voltage on the thermal resistance.
  • When the temperatures reaches at the certain threshold the output high and low signal threshold adjustable via potentio-meter , Its the task of digital output.
4. Flame Sensor Circuit Diagram
  • Flame sensor diagram is shown in the figure given below.
5. Apparatus Required for Flame Sensor Interfacing with Arduino
  • Arduino UNO (Micro-controller)
  • Flame Sensor
  • Jumper wires
  • Wero board
  • Light or another flame sensor
6. Flame Sensor & Arduino Pin Connections
  • Connections between Arduino and flame sensor pins are given in the table shown in the figure below.
7. Flame Sensor Arduino Interfacing - Wiring Diagram
  • Before hardware interfacing, you can also test your result on Proteus.
  • For Proteus simulation, you need to know about How to get Hex File from Arduino.
  • I have shared a brief tutorial on Interfacing of Flame Sensor with Arduino in my previous tutorial.
  • I have given a completely labeled wiring diagram for Flame Sensor Arduino Interfacing.
  • You can test & verify your results by making the same wiring diagram.
  • Wiring diagram for Flame Sensor Arduino Interfacing is shown in the figure given below.
8. Flame Sensor Interfacing with Arduino Source Code & Description
  • If you haven't written Arduino code ever, you must go through How to Write Arduino Code.
  • You just need to copy & to paste the complete source code given below in your Arduino software.
  • And just upload the code onto your Arduino board in order to verify the results.
int led_pin = 13 ;// initializing the pin 13 as the led pin

int flame_sensor_pin = 2 ;// initializing pin 7 as the sensor output pin
int flame_pin = HIGH ; // state of sensor

void setup ( )  {

  pinMode ( led_pin , OUTPUT ); // declaring led pin as output pin
  pinMode ( flame_sensor_pin , INPUT ); // declaring sensor pin as input pin for Arduino
  Serial.begin ( 9600 );// setting baud rate at 9600
}

void loop ( ) {
   flame_pin = digitalRead ( flame_sensor_pin ) ;  // reading from the sensor
  if (flame_pin == LOW )  // applying condition
  {
    Serial.println ( " FLAME , FLAME , FLAME " ) ;
    digitalWrite ( led_pin  , HIGH ) ;// if state is high, then turn high the led
  }
  
  else
  {
    Serial.println ( " no flame " ) ;
    digitalWrite ( led_pin , LOW ) ;  // otherwise turn it low
  } 
}
  • First of all I have defined the pins for led and the flame sensor.
  • The I have printed the digital information on the Serial Monitor obtained from the flame sensor.
  • The messages are displayed on the serial monitor via Serial Communication.
9. Flame Sensor Interfacing with Arduino
  • The actual circuit diagram for flame sensor interfacing with Arduino.
10. Flame Sensor Applications
  • Flame sensor has a lot of different applications.
  • Some of them are given below.
The tutorial Flame Sensor Interfacing with Arduino has explained the entire necessary detail about the flame sensor interfacing with Arduino. If you have any kind of problem you can ask me in comments anytime. I will try my level best to solve your issues. I hope you have enjoyed this tutorial. I will share other informative topics in my upcoming tutorials. Till my next tutorial take care and bye :)

Arduino Keypad Interfacing

Hello everyone! I hope you all will be absolutely fine and having fun. Today, we are going to work on Arduino Keypad Interfacing. First of all, I would like to tell you a bit about the keypad. After getting the basic idea about the keypad, we will start our discussion about Arduino Keypad Interfacing.  You should also have a look at Interfacing of Keypad with PIC Microcontroller.

In this tutorial, I am going to use a 4×4 keypad. It has sixteen buttons having four alphabetic characters. Let's have a look at the Arduino Keypad Interfacing:

Where To Buy?
No.ComponentsDistributorLink To Buy
1Jumper WiresAmazonBuy Now
2Keypad 4x4AmazonBuy Now
3Arduino UnoAmazonBuy Now

What is Keypad?

  • The keypad consists of multiple buttons, arranged in the form of a matrix(rows & columns) and is used in embedded projects.
  • They are cost-efficient and are easily available from online electronic stores.
  • Keypads are normally available in a 3×3, 4×3 and 4×4 format.
  • Keypad has several applications in real life based projects e.g. mobile phones, calculators, laptops, personal computers, television remote, toy remote, microwave oven, photocopy machine, bank’s ATM machine, tablets and a lot more.
  • A simple 4x4 Keypad is shown in the figure given below:
 

Keypad Pinout

  • I am using a 4×4 keypad in this tutorial, it has total of eight (8) pins.
  • All of these pins are provided in the table shown in the figure below:
  • From the above table, we can see that keypad’s first four pins are associated with its four rows.
  • The last four pins are assigned to the four columns of the keypad.
  • 4×4 Keypad’s pins functions are listed in the table provided in the figure given below.

Components Required for Arduino Keypad Interfacing

  • Components required for this project are:
    • Arduino UNO.
    • 4x4 Keypad.
    • Jumper Wires(Male to Female).

Keypad & Arduino Connections

  • The connections between the keypad and Arduino are provided in the figure given below:

Circuit Diagram of Keypad Arduino Interfacing

  • I have made a circuit diagram for keypad interfacing with Arduino.
  • A complete labeled circuit diagram is given in the figure shown below:
  • You can make a similar diagram and can easily test & verify your results on the serial monitor.

Arduino Code

  • You just need to copy this code into your Arduino software.
  • After successfully uploading the code to your Arduino board you will be able to verify the results.
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

void setup(){
  Serial.begin(9600);
}
  
void loop(){
  char customKey = customKeypad.getKey();
  
  if (customKey){
    Serial.println(customKey);
  }
}
  • First of all, I have defined the number of rows and columns of the keypad.
  • Then I have declared the complete keypad characters in terms of rows and columns.
  • After that, I have defined the row and column pin of the keypad attached to the Arduino pins.
  • Then I have simply read the data sent from the keypad and displayed it on the serial monitor.
  • You can download a completely labeled wiring diagram and Arduino source code here by clicking on the below button:
Wiring Diagram & Arduino Code

In the tutorial Keypad Interfacing with Arduino, I have explained the basics of the keypad as well as the keypad interfacing with Arduino UNO. I have tried my level best to cover up all the necessary information. If you found something missing, please let me know then. I will update my tutorial correspondingly as soon as possible. I hope you have enjoyed the complete tutorial and I am hoping for your positive response. If you have any problem you can freely ask as in comments anytime. I will share different topics in my upcoming tutorials. Take care and bye till the next tutorial :)

Introduction to ATmega328

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to give you a detailed Introduction to ATmega328. ATmega328 is an Advanced Virtual RISC (AVR) microcontroller. It supports 8-bit data processing. ATmega-328 has 32KB internal flash memory.

ATmega328 has 1KB Electrically Erasable Programmable Read-Only Memory (EEPROM). This property shows if the electric supply supplied to the micro-controller is removed, even then it can store the data and can provide results after providing it with the electric supply. Moreover, ATmega-328 has 2KB Static Random Access Memory (SRAM). Other characteristics will be explained later. ATmega 328 has several different features which make it the most popular device in today's market. These features consist of advanced RISC architecture, good performance, low power consumption, real timer counter having separate oscillator, 6 PWM pins, programmable Serial USART, programming lock for software security, throughput up to 20 MIPS etc. Further details about ATmega 328 will be given later in this section.

Note:
  • Here's the link to download the Atmega328 datasheet, although after reading this article you won't need it. :)
  • Moreover, I have also given the link to a reliable online source from where you can buy it easily.
Download Atmega328P Datasheet
Where To Buy?
No.ComponentsDistributorLink To Buy
1Arduino UnoAmazonBuy Now

Introduction to ATmega328

  • ATmega328 is an 8-bit, 28-Pin AVR Microcontroller, manufactured by Microchip, follows RISC Architecture and has a flash-type program memory of 32KB.
  • Atmega328 is the microcontroller, used in basic Arduino boards i.e Arduino UNO, Arduino Pro Mini and Arduino Nano.
  • It has an EEPROM memory of 1KB and its SRAM memory is 2KB.
  • It has 8 Pins for ADC operations, which all combine to form PortA ( PA0 - PA7 ).
  • It also has 3 built-in Timers, two of them are 8 Bit timers while the third one is 16-Bit Timer.
  • You must have heard of Arduino UNO, UNO is based on atmega328 Microcontroller. It's UNO's heart. :)
  • It operates ranging from 3.3V to 5.5V but normally we use 5V as a standard.
  • Its excellent features include cost-efficiency, low power dissipation, programming lock for security purposes, real timer counter with separate oscillator.
  • It's normally used in Embedded Systems applications. You should have a look at these Real Life Examples of Embedded Systems, we can design all of them using this Microcontroller.
  • The following table shows the complete features of ATmega328:
ATmega328 Features
No. of Pins 28
CPU RISC 8-Bit AVR
Operating Voltage 1.8 to 5.5 V
Program Memory 32KB
Program Memory Type Flash
SRAM 2048 Bytes
EEPROM 1024 Bytes
ADC 10-Bit
Number of ADC Channels 8
PWM Pins 6
Comparator 1
Packages (4) 8-pin PDIP 32-lead TQFP 28-pad QFN/MLF 32-pad QFN/MLF
Oscillator up to 20 MHz
Timer (3) 8-Bit x 2 & 16-Bit x 1
Enhanced Power-on Reset Yes
Power Up Timer Yes
I/O Pins 23
Manufacturer Microchip
SPI Yes
I2C Yes
Watchdog Timer Yes
Brownout detect (BOD) Yes
Reset Yes
USI (Universal Serial Interface) Yes
Minimum Operating Temperature -40 C to +85 C

ATmega328 Pins

  • ATmega-328 is an AVR Microcontroller having twenty-eight (28) pins in total.
  • All of the pins in chronological order, are listed in the table shown in the figure given below.
Now let's have a look at the pinout of Atmega328 in detail:

ATmega328 Pinout

  • Through the pinout diagram, we can understand the configurations of the pins of any electronic device, so you are working on any Engineering Project then you must first read the components' pinout.
  • ATmega328 pinout diagram is shown in the figure given below:

ATmega328 Pins Description

  • Functions associated with the pins must be known in order to use the device appropriately.
  • ATmega-328 pins are divided into different ports which are given in detail below.
  • VCC is a digital voltage supply.
  • AVCC is a supply voltage pin for analog to digital converter.
  • GND denotes Ground and it has a 0V.
    • Port A consists of the pins from PA0 to PA7. These pins serve as an analog input to analog to digital converters. If analog to digital converter is not used, port acts as an eight (8) bit bidirectional input/output port.
    • Port B consists of the pins from PB0 to PB7. This port is an 8 bit bidirectional port having an internal pull-up resistor.
    • Port C consists of the pins from PC0 to PC7. The output buffers of port C has symmetrical drive characteristics with source capability as well high sink.
    • Port D consists of the pins from PD0 to PD7. It is also an 8 bit input/output port having an internal pull-up resistor.
  • All of the AVR ports are shown in the figure given below.
  • AREF is an analog reference pin for analog to digital converter.
  • So this was the brief of all the pins in the ATmega328 AVR micro-controller.

ATmega328 Architecture

  • An architecture of a device presents information about the particular device.
  • ATmega-328 architecture is shown in the figure given below.

ATmega328 Memory

  • ATmega 328 has three types of memories, named:
    • Flash Memory: 32KB. It is a Programmable Read-Only Memory (ROM). It is a nonvolatile memory.
    • SRAM: 2KB. Stands for Static Random Access Memory. It is a volatile memory i.e. data will be removed after removing the power supply.
    • EEPROM: 1KB. Stands for Electrically Erasable Programmable Read-Only Memory.
  • AVR memory spaces are shown in the figure given below.

ATmega328 Registers

  • ATmega-328 has thirty-two (32) General Purpose (GP) registers.
  • These all of the registers are part of Static Random Access Memory (SRAM).
  • All the registers are given in the figure shown below.

ATmega328 Packages

  • The different versions of the same device are denoted by the different packages of that device.
  • Each package has different dimensions, in order to differentiate easily.
  • ATmega 328 packages are given in the table shown in the figure given below.

ATmega328 Block Diagram

  • The Block diagram shows the internal circuitry and the flow of the program of any device.
  • ATmega 328 block diagram is shown in the figure given below.

ATmega328 Features

  • To perform any task we can select a device on the basis of its features. i.e whether its features match to obtain the desired results or not.
  • Some of the main features of an AVR Microcontroller ATmega328 are shown in the table given in the figure below.

ATmega328 and Arduino

  • ATmega328 is the microcontroller used in the Arduino UNO board.
  • When we upload code in Arduino UNO, it's actually uploaded in the Atmega328 Microcontroller.
  • A software driver called bootloader is pre-installed in the flash memory of the Atmega328 microcontroller, which makes it compatible with Arduino IDE.
  • AVR Atmega328 attached on Arduino is shown in the figure given below:

ATmega328 and Arduino Pins

  • ATmega328 pins are connected to the corresponding pins of Arduino.
  • Their connectivity with each other is shown in the pinout diagram shown in the figure given below.
  • The encircled section analog pins consist of the Arduino pins which are connected to the corresponding AVR micro-controller ATmega-328 pins.
  • I have written both of the pins in front of each other, it will help to understand easily.
  • If you want to work on this Arduino board then you must try these Arduino Projects for Beginners, they will help to get your hands on Arduino.

Applications of Atmega328

  • A complete package including ATmega 328 and Arduino can be used in several different real-life applications.
  • It can be used in Embedded Systems Projects.
  • It can also be used in robotics.
  • Quad-copter and even small aero-plane can also be designed through it.
  • Power monitoring and management systems can also be prepared using this device.
  • I have designed this Home Security System using Arduino UNO, you should have a look at it.

How to start working on Atmega328

  • If you want to start working on this Microcontroller then I would suggest you do it using Arduino.
  • The benefit of using Arduino is that you get to use all of its built-in libraries, which will make the work a lot easier.
  • After designing your project on Arduino, then design the basic circuit of Atmega-328 which is quite simple and I have discussed above.
  • Now you must be careful while using its Pins, Atmega328 and Arduino Pins are discussed above.
  • Another thing to mention here is that before working on hardware, you should first design its Proteus Simulation.
  • Download Arduino Library for Proteus and then design your project on it.
  • Once you are confirmed that everything's correct then design its circuitry on Wero Board or PCB (Printed Circuit Board) and you have your project ready. :)
The tutorial Introduction to ATmega328 has the presented a detailed discussion on the basic use of ATmega 328. I have completely provided the entire necessary details about the use of an AVR micro-controller. If you have any problems, you can ask us in the comments anytime. Our team is always here to help you guys. I will share other amazing topics with all of you in my upcoming tutorials. So, till then take care :)

Arduino Projects for Beginners

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to elaborate you, how to make Arduino Projects for beginners. Before gong into the detail of this tutorial first of all I would like to explain you a bit about Arduino. Arduino is an open source micro controller. A lot of help is available online so its user friendly hardware. Most of the students prefer to do work on this device. Arduino is a low cost high performance device. Due to its cost effectiveness and open source feature it is commonly available in the market these days. An amazing thing about Arduino is that students can take help online with a lot of examples regarding any of the task. There are thousands of Arduino projects are available online from beginner level to the major real life projects. Students can make their own projects without having a lot of programming experience. Arduino kits for the beginners are also available in the market now a days. These kit usually consist of an Arduino board, jumper wires, motors, LED's, sensors, relays etc. Arduino has a very wide of real life applications including automation, robotics, remote control, LED's, environmental sensing, Internet of Things (IoT), display, monitoring etc. Further detail about this tutorial will be given later.

Arduino Projects for Beginners

In this section of the tutorial Arduino Projects for beginners, I will elaborate you how to make basic and very simple projects using Arduino which will lead you to the better and better understanding of Arduino environment later. With the help of such a projects you will be much confident and will be able to make large projects too. So here I am going to share some of the basic and beginners level Arduino projects from my blog.
Arduino Basic Projects
In this section I will provide Proteus ISIS libraries for the different Arduino boards e.g. Arduino Nano, Arduino UNO, Arduino Mega 2560 etc and other different projects too. Here is the list of those projects.
  1. Getting Started with Arduino Software
  2. Arduino Library for Proteus
  3. Arduino UNO Library for Proteus
  4. Arduino Genuino Library for Proteus
  5. Arduino Lilypad Library for Proteus
  6. Arduino Mega 2560 Library for Proteus
  7. Arduino Nano Library for Proteus
  8. Arduino Pro Mini Library for Proteus
  9. Arduino UNO PCB Design for Proteus
  10. Arduino Library for Seven Segment Display
  11. How to get .hex File from Arduino
  12. How to use Arduino Software Serial
  13. How to use Arduino Serial Flush
  14. How to use Arduino Serial Read
  15. Ultrasonic Sensor Library for Proteus
  • These are the very basic Arduino Projects, a student must go through all of these projects for the better understanding of the other projects.
  • Now, I am going to share all of the mini projects designed by our team using Arduino board.

1. A Simple Arduino LED Example in Proteus

In this tutorial I have shared an LED control example using Arduino UNO in Proteus ISIS. I have designed the circuit to control a single LED using Arduino in Proteus. First I have testes and verified the control of an LED using Arduino. After its successful testing I have designed another circuit in Proteus to control a bundle of LED using the Same Arduino board. You can also check the blinking of an on board LED attached to the pin 13 of Arduino board. I have provided the complete Proteus ISIS design and Arduino source code for your easiness.
  • You can download the entire package here by clicking on the button below.

Download Simulation

  • Download .rar file, extract it and enjoy the simulation.

2. Circuit Designing of LCD with Arduino in Proteus

In this tutorial I have shared the design of a circuit for LCD interfacing with Arduino UNO in Proteus ISIS. I have used LCD here basically for debugging purpose in order to check whether the Arduino source code is in working condition or not. I have designed the Proteus simulation first and then I wrote source code in Arduino software. At the end after uploading .hex file in Arduino I have verified the code as show in the figure.
  • You can download the entire package here by clicking on the button below.

Download Simulation

  • Click on the button above and go through the detailed discussion.

3. Interfacing of Keypad with Arduino in Proteus ISIS

In this article I have elaborated the circuit designing of keypad with Arduino UNO. I have used 4*3 keypad. Keypads are most common in a lot of real life applications such as calculators, laptops, ATM machined etc. The functionality of keypad is based on matrix systems. I have interfaced Arduino UNO, LCD and keypad in such a way that the text is displayed on LCD with respect to the corresponding buttons pressed from the keypad.
  • You can download the entire package here by clicking on the button below.

Download Simulation

  • Download the file, extract it and enjoy the simulation.

4. Scrolling Text on LED Matrix 8*8 using Arduino in Proteus ISIS

This part of this tutorial will explain the design for scrolling text on LED matrix 8*8 using Arduino in Proteus ISIS. I have used an LED matrix. It is basically used to display long messages that we want to write on it. I have designed the complete circuit simulation in Proteus ISIS. Then I have written the Arduino source code. After uploading the code I have verified the results as well. They were absolutely perfect. Our team has done a lot of hard work to design this project. So, I have imposed a very lost on it that a student can easily buy this project even with his pocket money.
  • You can buy this project here by clicking on the button below.

Buy Simulation & Arduino Source Code

5. Ultrasonic Sensor Simulation in Proteus

This article presents the detailed discussion about the circuit designing for interfacing of SONAR with Arduino UNO. I have used the library for ultrasonic sensor whose link is given above. This sensor is very to interface using this library. I have shared three type of examples regarding ultrasonic sensor interfacing with Arduino in Proteus ISIS. These examples include ultrasonic sensor interfacing using buttons, as a proximity switch and as a switch. I have provided both Proteus simulation as well as Arduino source code.
  • You can download the entire package here by clicking on the button below.

Download Simulation

  • Download the file, extract it and enjoy the simulation.

6. Interfacing of Temperature Sensor 18B20 with Arduino

  The detailed discussion about circuit designing and interfacing of temperature sensor with Arduino UNO is given in this section of the tutorial Arduino projects for beginners. I have used non-water proof temperature sensor. I have used an LCD as well to print the values obtained from the temperature sensor. We can get the values of temperature in Celsius using 18B20. There is a library for Arduino while interfacing 18B20 with it. I have shared that library too.
  • You can download the entire package containing both simulation and Arduino library for 18B20 here by clicking on the button below.

Download Library & Simulation

  • Download the file, extract it and enjoy the simulation.

7. Interfacing of Temperature Sensor LM35 with Arduino in Proteus ISIS

This section of the tutorial Arduino projects for beginners, will provide you the discussion about the circuit designing of L35 interfacing with Arduino in Proteus. LM35 is a low cost sensor as compared to the other temperature sesnsors e.g. 18B20. I have designed the circuit in Proteus ISIS first and then I have written the code in Arduino software. After that I have tested the written code and verified the results. There were absolutely accurate. I have provided both simulation and code for free.
  • You can download the entire package here by clicking on the button below.

Download Simulation & Code

  • Download the file, extract it and enjoy the simulation.

8. Interfacing PIR Sensor with Arduino

The detailed discussion about the interfacing of PIR sensor with Arduino is given in this section of the tutorial Arduino projects for beginners. PIR sensor is designed for motion detection purposes. PIR sensor is a passive device and does not generate its own voltages and energy. I have provided the complete circuit diagram of PIR interfacing with Arduino as well as the source code in Arduino software. You can also read the detailed discussion here by clicking on the button below.

Download Simulation

  • Download source code and circuit diagram and enjoy the simulation.

9. Interfacing Flame Sensor with Arduino

In this section of the tutorial Arduino projects for beginners, I have given the detailed discussion about interfacing flame sensor with Arduino UNO. Flame sensor is designed basically fire detection purposes or you can say for temperature monitoring purposes. You have to set a threshold value and above that value an LED on the top of the sensor will be turn on as an indication. I have designed its Proteus ISIS simulation first. Then I have written its source code in Arduino software. I have uploaded the code in Arduino in Proteus and observed the results, they were quite accurate. You have to change the state of logic state from 0 to 1. As the state becomes the sensor will start working and a corresponding test will be displayed on LCD. I have provided the complete simulation and source code for this project.
  • You can download the entire package here by clicking on the button below.

Download Simulation & Arduino Source Code

  • Download source code and circuit diagram and enjoy the simulation.

10. Interfacing NRF24L01 Sensor with Arduino

This section of the tutorial Arduino projects for beginners, will give you the detailed discussio nabout the interfacing of NRF24L01 sensor with Arduino UNO. NRF24L01 is basically used for wireless communication between two different nodes.It operates on a frequency equal to WiFi frequency i.e. 2.4GHz. This sensor has a capability to send and receive data at the same time. I have provided Arduino library for NRF24L01, complete circuit diagram and Arduino source code for this project for free. You can easily design your own circuit with the help of this article.
  • You can download the entire simulation and source code here by clicking on the button below.

Download Simulation & Arduino Source Code

  • Download source code and circuit diagram and enjoy the simulation.

11. Interfacing RFID RC522 with Arduino

In this section I will elaborate you the method for interfacing RFID RC522 with Arduino. I have used a breadboard and jumper wires to make a connection between RFID RC522 and Arduino UNO. RFID RC522 is used in the projects where there is a need of wireless communication between laptop/PC and the micro controller. I have provide the pins configuration of Arduino as well as RFID RC522 sensor. I have also provided the library for RFID, a complete circuit diagram of in terfacing this module with Arduino as well as the source code to operate this module.
  • You can download the library, circuit diagram and source code here by clicking on the button below.

Download Simulation & Arduino Source Code

  • Download source code and circuit diagram and enjoy the simulation.

12. Control Servo Motor with Arduino in Proteus

This section of the tutorial Arduino Projects for Beginners, will provide explanation about control of a servo motor with Arduino in Proteus ISIS. Servo motor is commonly used in the projects where there is a need of high precision like CNC machines, robotics are such fields where high precised results are required. So, servo motors are the best option in such cases. I have designed a complete circuit for interfacing of a stepper motor with Arduino UNO in Proteus ISIS. I have provided the complete Arduino source code as well. After uploading the source code in Arduino you will be able to control the servo motor in Proteus ISIS.
  • You can download the complete simulation and source code here by clicking on the button below.

Download Simulation & Arduino Source Code

  • Download source code and circuit diagram and enjoy the simulation.

13. Home Automation Project using XBee and Arduino

In this tutorial I have explained all of the steps about making a home automation project using XBee and Arduino UNO. Now a says, since every thing is going under automation. So, I thought to design a pretty simple automation projects named as home automation project. Home automation project has the features e.g. you can control the entire appliances of the home from your PC or Laptop sitting anywhere in the world. This features required internet services. First of all I have designed the complete circuit as shown in the figure as well. I have designed the circuit to control the home using remote. I have written Arduino source code and after uploading the code in Arduino I have tested the projects and it was operating well. Our team has designed this project with a lot of hard work so we have imposed a very small amount of cost on it. Even a student can but this project with his/her pocket money.
  • You buy the complete simulation as well the Arduino source code here by clicking on the button below.

Buy Simulation & Arduino Code

14. GSM Based Home Security System using Arduino

In this section of the tutorial Arduino projects for beginners, I have explained all of the necessary steps to design a GSM based home security system using Arduino. Some of people are very conscious and they want to secure there houses at any cost. So basically this type of project is pretty suitable for them. I have designed a complete Proteus ISIS simulation for home security system using Arduino and GSM. Then I have written a complete Arduino Source code and after uploading it on the Arduino board in Proteus I have tested the results which were quite efficient and precise. This project took a lot of hard work and time. So, we have imposed a small amount of cost on it as well.
  • You can buy this project easily here by clicking on the button below, its not costly at all.

Buy Simulation & Arduino Code

This tutorial contains a detailed discussion of Arduino Projects for Beginners. I have a lot of basic Arduino projects. Some of them were free of cost and some projects are assigned with a small amount cost. I have tried to share different easy and moderate level Arduino projects. If you have any problem you can freely ask us. Me and my team is 24/7 available here to entertain you and to help you out in some good manner. I will share other informative and helpful tutorials in my upcoming articles. Till then, Taker Care :)

Servo Motor Control using Arduino

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to tell you about how to design an algorithm for Servo Motor Control using Arduino. First of all I would like to tell you a bit about the servo motors. Servo motors are small devices having an output shaft. We can adjust this shaft in different angular positions by continuously sending the servo coded signal. Servo motor maintains the angular position of the shaft as long as the coded signal is present at the input. If the applied coded signal changes, angular position of the shaft of a servo motor also changes correspondingly. If you are working on Servo Motor then i would suggest you to must have look at this tutorial Servo Motor control in Proteus, as its always a best practice to design simulation first. In my previous tutorials I have controlled the direction and speed of the both DC as well as of the stepper motor. Ordinary DC motor has only two input terminals. When power is supplied it simply starts to rotate continuously. In comparison to the DC motor servo motor has three wires. Using servo coded signal we can send commands to the servo motor that in what direction and with what angle it has to rotate. If we want to add motion in our electrical projects, servo motor will be an easy way to do so. Servo motor has a wide range of applications in our daily life e.g elevator, cars, robotics, puppets, remote controlled airplanes and cars, conveyor belts, solar tracking system, antenna positioning, textiles etc.Moreover, I have also controlled the Servo Motor with PIC Microcontroller, so if you are using PIC Microcontroller then have a look at that one.

Servo Motor Control using Arduino

In the tutorial Servo Motor Control using Arduino, I will tell you step by step procedure for connecting the servo motor with Arduino and how to design a algorithm in Arduino software to control its angular position with the help of servo coded signal. First of all I would like to tell you about the hardware components necessary for Servo Motor Control using Arduino.
  • You can download the complete Arduino source code here by clicking on the button below.

  • Just download .rar file, extract it and enjoy the complete source code.
Hardware Required
A complete list of the hardware equipment necessary for this task is given below.
  • Computer/Laptop
  • Arduino UNO (Micro Controller)
  • Appropriate USB Cable
  • Servo Motor (4.8 to 6.0V with 2.5 kgf-cm torque)
  • Jumper Wires (Cables)
Arduino UNO acts as the backbone of this task. It sends the servo encoded signal to the servo motor to control its angular movement. Arduino UNO board is shown in the figure below. Servo Motor having torque of 2.5kgf-cm and 4.8-6.0v is used for this project. The selected servo motor is shown in the figure below. Power of 5V is supplied to the servo motor from the Arduino UNO board. Jumper Wires are used to make the connections of the all the components in order to make the complete circuit with proper working. Jumper wires are shown in the figure below.
Circuit Diagram
  • The circuit diagram for Servo Motor Control using Arduino is shown in the figure below.
  • I have supplied 5V to red wire of the servo motor as shown in the above figure.
  • The black wire is the attached to the GND pin of the Arduino UNO.
  • Yellow wire is basically the wire used to control the angular motion as well as the angle of the servo motor.
Source Code Description
  • The complete Arduino source code for Servo Motor Control using Arduino is given below.
  • You have to just copy the code given below and to past it in your Arduino software.
  • By uploading the source code to your Arduino board you will be able to control the servo motor using Arduino.
#include <Servo.h> //library for servo motor

Servo myservo;  // servo motor object for its control

int ang = 0;    // a variable to store the servo angle

void setup() {

  Serial.begin(9600);
  
  myservo.attach(8);  // servo motor is attached to pin no 8 og Arduino

}

void loop() {

  for (ang = 0; ang <= 180; ang += 5) // goes from 0 degrees to 180 degrees with a step og 5 degree
  { 
    myservo.write(ang);              // rotates the servo to rotate at specific angle
    delay(50);     // adding delay of 50 msec
    Serial.println("Motor has started its rotation from 0 to 180 degress");
      }
  for (ang = 180; ang >= 0; ang -= 5) // goes from 180 degrees to 0 degrees with a step of 5 degree
  { 
    myservo.write(ang);              // rotates the servo to rotate at specific angle
    delay(50);                      // adding delay of 50 msec
    Serial.println("Motor has started its rotation from 180 to 0 degress");
      }
}
  • First of all I have inserted the library for servo motor.
  • Then I have created a servo object and declared the initial angle of the servo motor.
  • After that I have have adjust the baud rate, the rate at which Arduino communicates with the laptop/computer.
  • Then I have defined the pin at which the servo motor is attached to the Arduino UNO's board.
  • Inside the main loop, I have applied the condition that in between 0 and 180 degrees, the servo motor's angle will be increased with different steps and each step has 5 degrees of angular movement.
  • When maximum limit is reached, the angle will be reduced from 180 to 0 degree with different steps, each step having 5 degrees of angular movement.
  • That was the brief description of the Arduino complete source code designed for Servo Motor Control using Arduino.
That is all from the tutorial Servo Motor Control using Arduino. I hope you all have enjoyed this tutorial. If you face any sort of problem you can ask me freely in comments any time you want without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. I will explore Arduino by making different projects on it and will share all of them with all of you as well in my later tutorials. Till then, Take care :)

DC Current Sensor ACS712 Arduino Interfacing

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge with all of you guys about DC Current Sensor ACS712 Arduino Interfacing. First of all, I would like to tell you about importance of current sensing/measuring. Sensing the amount of current passing through any circuit can be useful in a lot of applications. For example, in low power consuming equipment, current sensing will be helpful to understand the system's impact on its battery life. The current sensing can also be used to make the decisions regarding safety in over current protection circuits. Simply, we can say that sensing and controlling the flow of the current through the circuits is now a fundamental requirement e.g. over current protection circuits, battery chargers, watt meters, power supplies etc.

DC Current Sensor ACS712 Arduino Interfacing

Basically, there are two types of current senors AC and DC. But, in the tutorial,I am going to do the DC Current Sensor ACS712 Arduino Interfacing, and we will learn about the sensing of the DC current. I will use ACS712 DC current sensor for sensing the DC current.
  • You can download the complete Arduino source code there.
  • Download .rar file, extract it and upload code in your Arduino board:

Components Required
Here I am going to tell you about the components necessary for this projects. The list of all the components is given below.
  • Arduino UNO
  • DC Current Sensor (ACS712)
  • DC Load
  • Wero Board
  • Soldering Iron
  • Soldering Gum
  • Jumper wires
  • Power Supply (12V)
  • 20 x 4 LCD
Description of the Components used
[ultimate_spacer height"10"] In this section of the tutorial Interfacing DC Current Sensor with Arduino, I will explain the reasons why I have used the specific components for this project.
  • Arduino UNO acts as the back bone of the project. It manipulates the whole source code uploaded to the board, prints the desired data on the serial monitor and also prints the executed commands on the LCD. You can use the same code of other Arduino boards as well i.e. Arduino Nano, Arduino Pro Mini etc.
  • Power Supply of 12V is used to turn the entire system ON. Because, we can not test and verify our system until we have not switched it ON. Power supply used for this project is shown in the figure. I have used this 9A Battery (I have this available) but you can use 1.5A small battery as well. Battery selection depends on your projects' power consumption.
  • LCD is used to display the digital values of the data which has been printed on the serial monitor of the Arduino software i.e all the executed commands will be printed on the LCD as well. The LCD which I have used for this is shown in the figure.
  • Jumper Wires are used to make the connections of the all the components, in order to make the complete circuit with proper working. Jumper wires are shown in the figure. There are 3 types of Jumper wires available: Male to Male, Male to Female & Female to Female.
  • ACS712 is used to sense the Direct Current (DC) flowing through the any circuit. The DC current sensor used is shown in the figure.
Flow Chart
[ultimate_spacer height="5"]
  • Here, I would like to explain the entire algorithm with the help of a flow chart for DC Current Sensor ACS712 Arduino Interfacing.
  • The flow chart for this project DC Current Sensor ACS712 Arduino Interfacing is shown in the figure.
  • First of all, I have initialized the Serial Port.
  • After that we are reading the value from our current sensor ACS712.
  • Then data will be displayed on the LCD and Serial Monitor.
Circuit Diagram
  • The complete wiring diagram for this project is shown in the figure below.
  • You can run this project properly, by making the circuit first, identical to the circuit diagram shown in the figure above.
  • The digital pin 0 of the Arduino UNO will help us in reading the data from the sensor.
  • The other two pins of the sensor are connected to the supply of 5V and ground respectively as you can see from the above figure.
Source Code Description
  • The source code for this project DC Current Sensor ACS712 Arduino Interfacing is given below.
  • You have to just copy and paste the code given below in your Arduino software after properly interfacing DHT11 with the Arduino.
  • After uploading the code onto your Arduino board you will be able to observe the humidity and temperature and humidity level on serial monitor.
// include the library code:
#include <LiquidCrystal.h> //library for LCD

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

//Measuring Current Using ACS712

const int analogIn = 0; //Connect current sensor with A0 of Arduino
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
int RawValue= 0;
int ACSoffset = 2500; 
double Voltage = 0; //voltage measuring
double Amps = 0;// Current measuring

void setup() {
  //baud rate
  Serial.begin(9600);//baud rate at which arduino communicates with Laptop/PC
  // set up the LCD's number of columns and rows:
  lcd.begin(20, 4);  //LCD order
  // Print a message to the LCD.
  lcd.setCursor(1,1);//Setting cursor on LCD
  lcd.print("www.TheEngineering");//Prints on the LCD
  lcd.setCursor(4,2);
  lcd.print("Projects.com");
  delay(3000);//time delay for 3 sec
  lcd.clear();//clearing the LCD display
  lcd.display();//Turning on the display again
  lcd.setCursor(1,0);//setting LCD cursor
  lcd.print("Reading Values from");//prints on LCD
  lcd.setCursor(1,1);
  lcd.print("DC Current Sensor");
  lcd.setCursor(5,2);
  lcd.print("ACS 712");
  delay(2000);//delay for 2 sec
}

void loop() //method to run the source code repeatedly
{
 
 RawValue = analogRead(analogIn);//reading the value from the analog pin
 Voltage = (RawValue / 1024.0) * 5000; // Gets you mV
 Amps = ((Voltage - ACSoffset) / mVperAmp);
 
//Prints on the serial port
 Serial.print("Raw Value = " ); // prints on the serial monitor
 Serial.print(RawValue); //prints the results on the serial monitor
 
 lcd.clear();//clears the display of LCD
 delay(1000);//delay of 1 sec
 lcd.display();
 lcd.setCursor(1,0);
 lcd.print("Raw Value = ");
 lcd.setCursor(13,0);
 lcd.print(RawValue);
 
 Serial.print("\t mV = "); // shows the voltage measured 
 Serial.print(Voltage,3); // the '3' after voltage allows you to display 3 digits after decimal point
 
 lcd.setCursor(1,1);
 lcd.print("Voltage = ");
 lcd.setCursor(11,1);
 lcd.print(Voltage,3);
 lcd.setCursor(17,1);
 lcd.print("mV");//Unit for the voltages to be measured
 
 Serial.print("\t Amps = "); // shows the voltage measured 
 Serial.println(Amps,3);// the '3' after voltage allows you to display 3 digits after decimal point
 
 lcd.setCursor(1,2);
 lcd.print("Current = ");
 lcd.setCursor(11,2);
 lcd.print(Amps,3);
 lcd.setCursor(16,2);
 lcd.print("A"); //unit for the current to be measured
 delay(2500); delay of 2.5 sec
}
  • I am going to explain you that how this code is working!
  • Then I have defined the library for LCD.
  • I have defined the pin at which DC current sensor is attached with the Arduino board.
  • Then I have defined the Arduino pins at which the LCD is interfaced.
  • Then by opening the serial port I have started to print the level of temperature and humidity on the serial monitor as well as on the 20×4 LCD.
  • At the end, I have added the delay of few seconds so that the speed of the data to be printed on the serial monitor can be reduced to some extent in order to observe properly.
  • This was the brief description of the source code.
This is all from the tutorial DC Current Sensor ACS712 Arduino Interfacing. I hope you all enjoyed this tutorial. If you face any sort of problem you can ask me anytime in comments without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. I will explore Arduino further in my later tutorials. Till then, Take care :)

Scrolling Text on LCD with Arduino

Hello everyone! hope you all will be fine. In this article I am going to share the knowledge about displaying Scrolling Text on LCD with Arduino. A Liquid Crystal Display is usually known as LCD in the market. It is a display unit made up of liquid crystal. When we want to made electronics based projects, we need a device on which we can show the system’s output and the desired messages. There are a lot of such devices which are helpful to display the output messages and the most common is a seven segment display. Alternate good option is LCD, which are now available in different size having different qualities. 16×2 LCD Module is a most frequently used device for the electronic projects out of all the other types of LCD’s available in the market. 32 ASCII characters can be displayed on it simultaneously in 2 rows i.e. it has a capacity to show 16 characters per row. 20×4 LCD, 128×64 graphical LCD and 2.4 inch TFT Touch screen LCD are also used commonly for the electronic projects now-a-days in the market and as well as in the institutions.

Scrolling Text on LCD with Arduino

In the tutorial Scrolling Text on LCD with Arduino, we are going to learn how to interface a 16×2 lcd to Arduino UNO and how to display the scrolling text on LCD in Proteus ISIS. First I would like to write a simple code to print something on the LCD and then I will update the previously written code to scroll the text printed already on the LCD.
  • You candownload the complete simulation here by clicking on the button below.

Arduino Source Code

  • Just download .rar file, extract it and enjoy the complete simulation.
Interfacing 16×2 LCD to Arduino uno
LCD modules are most frequently used devices specially in Arduino based electronic projects. So it is essential to share this tutorial based on interfacing LCD module to Arduino UNO and displaying scrolling text on LCD with all of you. Interfacing of an Arduino UNO to 16×2 LCD is elaborated in this section. The selected LCD module has 16 pins. You can operate this module in 4 bit mode by using only four data lines (from D4 to D7) or 8 bit mode by using all the eight data lines (from D0 to D7). In this article we are using the LCD module operating in the 4-bit operational mode i.e. we are using only four data pins. I have divided this tutorial in two parts. First of all, I will explain how to display a simple text messages on the 16×2 LCD with Arduino UNO and secondly I will show that how to display scrolling text on the same LCD interfaced with Arduino UNO. Before the explanation of this design, let’s have a look at the selected LCD. You should also have a look at this New LCD Library for Proteus.
Designed Circuit in Proteus ISIS
Find Arduino UNO and a 16×2 LCD in the components library of proteus ISIS ISIS. If arduino library is present in your Arduino software then arduino will be shown in the components library otherwise you have to install Arduino library for proteus ISIS. Wiring diagram of the LCD module with Arduino UNO in proteus ISIS is shown in the figure below. You can download this Proteus Simulation from Interfacing of LCD with Arduino.
  • .Now just copy and paste the given source code in the Arduino software
#include<LiquidCrystal.h> //Library for LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);// LCD pins at which it is attached to the Arduino

void setup() //method used to run the source for the one time onlys
{
  lcd.begin(16, 2);//LCD order i.e. 16 columns & 2 rows
  lcd.print("The Engineering Projects ");//prints on LCD
  lcd.setCursor(0,1);//setting cursor on LCD
  lcd.print("www.TheEngineeringProjects.com");//prints on LCD
  delay(1000);//delay of 1 sec
}
void loop() //method to run the source code repeatedly 
{
 lcd.noDisplay();//turn off the display of LCD
 delay(250);//delay to 0.25 seconds
 lcd.display();//turning on the LCD display
 delay(250); //delay of 0.25 seconds again
}
  • Now compile the source code and get hex file from it as shown in the figure below.
  • Copy this address as shown in the figure above.
  • Double click on Arduino UNO in proteus, a new window will be opend as shown in the figure below.
  • Paste that address in the file menu as encircled in the figure below.
  • Run the proteus simulation from the Arduino software from the upper left corner of the software.
  • If everything goes perfect you will see the output as shown in the figure below.
  • Copy and paste the source given below in your Arduino software.
#include <LiquidCrystal.h>//Library for LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);//LCD pins at which it is attached to the Arudino

void setup()//method used to run the code for once 
{
  lcd.begin(16, 2);//LCD order
  lcd.print("The Engineering Projects ");//prints on LCD
  lcd.setCursor(0,1);//Setting the cursor on LCD
  lcd.print("www.TheEngineeringProjects.com");//prints on LCD
  delay(1000);//delay of 1 second
}

void loop() //used to run the code repeatedly
{
 for(int PositionCount=0;PositionCount<13; PositionCount++)//loop for scrolling the LCD text
  {
    lcd.scrollDisplayLeft();//builtin command to scroll left the text
    delay(150);// delay of 150 msec
    }

   for(int PositionCount=0; PositionCount<29; PositionCount++)
   {
    lcd.scrollDisplayRight(); //builtin command to scroll right the text
    delay(150);//delay of 150 msec
    }
   for(int PositionCount=0; PositionCount<16; PositionCount++)//loop for scrolling the text
   {
    lcd.scrollDisplayLeft();//builtin command to scroll the text left again
    delay(150);//delay of 150 msec
    }
}
  • Compile the code given above.
  • Obtain the hex file as I told above in the figure.
  • And open it in your proteus as I described above.
  • Run the simulation like the I have previously done.
  • You will be able to see the scrolling text on LCD as shown in the figure below.
  • That all from this article to show Scrolling Text on LCD using Arduino.
  • Was it difficult? I don't think so :)
So, that is all from the tutorial Scrolling Text on LCD using Arduino. I hope you enjoyed this tutorial. If you face any sort of problem, you can ask me in the comments any time. I will try my level best to solve your issues in a better way, if possible. I will explore Arduino by making different projects on it and will share them with you as well. Till then, take care :)

Stepper Motor Speed Control using Arduino

Hello everyone! I hope you all will be absolutely fine and fun. Today, I am going to tell you that how to make a simple algorithm for Stepper Motor Speed Control using Arduino. I have already discussed with you about DC Motor Direction Control using Arduino, Matlab and NI LabVIEW. Moreover, I have also discussed the DC Motor Speed Control using Arduino,Matlab and LabView. If you are working on Stepper Motor, then you must have a look at Stepper Motor Direction Control using Arduino, Stepper Motor Direction Control using Matlab and Stepper Motor Direction Control using NI LabVIEW. Now, in this tutorial I will explain you about the program which will helpful for Stepper Motor Speed Control using Arduino. Before going into the details of this tutorial you must have go through my previous tutorials because I am using the same hardware. So, they will be a lot helpful for the better understanding of this tutorial. In this tutorial I will explain you about making an Arduino program for Stepper Motor Speed Control using Arduino with the help of the serial communication. If the stepper motor is rotating at its maximum speed and you are continuously sending the command through the serial port to reduce its speed, it s speed will be reduced in proportion to the number of command sent through the serial port. Similarly the same procedure will be followed to increase the speed of the stepper motor.

Stepper Motor Speed Control using Arduino

In the tutorial Stepper Motor Direction Control using Arduino, I will explain you about making an algorithm to run the stepper motor at different speed. If the stepper motor is already running at its maximum speed and you want want to accelerate it further then nothing will happen to the speed of the stepper motor. If the stepper motor is rotating slowly and you enhance its speed, then the speed of the motor will increase in proportion to the number of accelerating command sent through the serial port.
  • You can download the complete Arduino source code here by clicking on the button below.

Download Arduino Code

  • Download .rar file, extract it and enjoy the complete source code.
Flow Chart
  • I have made a flow chart so that you can easily understand the entire algorithm because sometimes it becomes difficult to understand the algorithm with the help of the source code.
  • Flow chart for the Stepper Motor Speed Control using Arduino is shown in the figure below.
  • First of all we need to start the serial port so that our communication could be started.
  • Then there is a method to check the speed, if the speed is greater than the maximum speed of the stepper motor then the program will wait for the next command.
  • If the stepper motor is not rotating with its maximum speed then we can increase its speed.
  • Similarly if the minimum speed of the stepper motor is reached then the program will rotate for the next commands.
  • If the minimum limit of the speed of the stepper motor is not reached then we have a option to reduce its further.
  • At the end we should close the serial port so that exchange of unnecessary commands through the serial port could be avoided.
Block Diagram
  • Block diagram will be helpful for use for the better understanding of the exchange of information.
  • It tells us that how the information is exchanged sequentially among all the components used.
  • Block diagram is shown in the figure below.
  • Arduino UNO communicates with the L298 motor controller to control the speed of the stepper motor.
  • L298 Motor controller manipulates the Arduino's commands and starts to control the speed of the stepper motor.
Arduino Code Description
In this section of the tutorial Stepper Motor Speed Control using Arduino, I am going to elaborate you about the Arduino source.
  • I have made two different functions for increasing (accelerating) the speed of the stepper motor and for decreasing (deaccelerating) the speed of the stepper motor respectively.
  • I have declared a variable named as count.
  • In Accelerate function, you have to send the command through the serial port to increase the speed of the stepper motor.
  • In this function, I am continuously increasing the value of the count i.e as many times you send the command the speed of the stepper motor will increase continuously.
  • The source code of the Accelerate function is given below.
   void Accelerate_Motor()
   { 
    count=count+10; //Speed will increase continuously as we continue to press H
    if (count>120)  //Speed must not be greater than 120
    {
      count=120;
      }
    Serial.println("Accelerating"); //printing on the serial port
    Serial.println("");//prints blank line on the serial port
    myStepper.step(stepsPerRevolution);//counter clockwise rotation
    myStepper.setSpeed(count); //Updating the speed of the motor
    lcd.setCursor(3,0);//setting LCD cursor
    lcd.print("Acelerating"); //printing on LCD
   }
  • In Deaccelerate function, you have to send the command through the serial port to increase the speed of the stepper motor.
  • In this function, I am continuously reducing the value of the count i.e as many times you send the command the speed of the stepper motor will reduce continuously.
  • The source code of the Deaccelerate function is given below.
void Deaccelerate()
{
  count=count-10; //reducing the speed of the motor
  if (count<20) //speed of the motor must not be less than 20
  {
    count=20;
    }
  Serial.println("Deaccelerating"); // prints on the serial port
  Serial.println(""); //prints blank line on the serial port
  myStepper.step(stepsPerRevolution);
  myStepper.setSpeed(count); //Updating the speed of the motor
  lcd.setCursor(3,0);  //setting cursor on LCD
  lcd.print("Deaccelerating"); //prints the command on LCD
  }
  • In the main source inside the loop I am calling both of these Accelerate and Deaccelerate functions.
  • The executed commands will also be printed on the LCD (Liquid Crystal Diode).
  • The main source code is given below.
#include <LiquidCrystal.h>//Library for LCD
#include <Stepper.h>     //Library for Stepper motor

const int stepsPerRevolution = 255;  

// initialize the stepper library on pins
Stepper myStepper(stepsPerRevolution, 4, 5, 6, 7);
char data;
int count = 120;
//LCD pins assigning
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
void setup() {
  // set the speed at 60 rpm
  myStepper.setSpeed(60);
  // initialize the serial port:
  Serial.begin(9600);// rate at which the arduino communicates

lcd.begin(20, 4);//LCD type

lcd.setCursor(3,0);//setting LCD cursor and printing on it
lcd.print("Stepper Motor");
lcd.setCursor(6,1);
lcd.print("Speed");
lcd.setCursor(5,2);
lcd.print("Control");
lcd.setCursor(2,3);
lcd.print("via Arduino UNO");

delay(3000);

lcd.clear ();//Clearing the LCD screen

lcd.setCursor(0,2);
lcd.print("www.TheEngineering");
lcd.setCursor(4,3);
lcd.print("Projects.com");
}

void loop() {
  if(Serial.available())
  {
    data = Serial.read(); //Reading the data from serial port
  }
  
    if(data == 'C'){Clockwise();}      //Clockwise rotation
    if(data == 'A'){AntiClockwise();} //Anti-clockwise rotation
    if(data == 'S')                  //stopping the stepper motor
    {
      data = 0; 
      lcd.setCursor(3,0);
      lcd.print("No rotation");
      Serial.println("No rotation");//print on the serial
      }   
     if(data == 'H'){Accelerate_Motor();}
     if(data == 'L'){Deaccelerate();}
}
Complete Hardware Setup
  • In this section of the tutorial, I will show you the complete hardware setup that I have used for this project.
  • Hardware consists of 12V power supply, Arduino UNO, L298 motor controller.
  • When you upload the code to the Arduino board the system will look like the figure shown below.
  • When you press to increase the speed of the stepper motor, the statement accelerating will be printed on the LCD.
  • The printed executed command is printed on the LCD and is shown in the figure below.
  • When you press to reduce the speed of the stepper motor, the statement Deaccelerating will be printed on the LCD.
  • The printed executed command is printed on the LCD and is shown in the figure below.
That is all from the tutorial Stepper Motor Speed Control using Arduino. I hope you all have enjoyed this tutorial. If you face any sort of problem regarding anything you can ask me anytime without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way if possible. I will explore Arduino by making further projects and I will share them with all of you as well in my later tutorials. So, till then, Take Care :)

Stepper Motor Direction Control using Arduino

Hello friends! I hope you all will be absolutely fine and having fun. Today, I will elaborate you that how can we make a simple algorithm for Stepper Motor Direction Control using Arduino. In my previous tutorials I made algorithm for DC Motor Direction Control using Arduino, DC Motor Direction Control using Matlab, DC Motor Speed Control using Arduino and DC Motor Speed Control using Matlab. Now, in this tutorial I will control a stepper motor using Arduino by entering the different commands through its serial port. Before going into the detail of this tutorial, you must know the basic difference between stepper and DC motors. DC motors have only two input terminal one is positive and the other one is negative. You just have to provide the power supply and it will start rotating but this is not the case in stepper motor. The stepper motor which I will use in this tutorial, has six pins out of which four pins provide pulses or steps and the other two pins are power pins. So, in this tutorial I will control this six pins stepper motor using L298 motor controller and Arduino UNO board. Basically we can use stepper motor where precision is required. Stepper motor has wide range of applications e.g robotics, CNC machines, home automation etc. In simple word, we can say that stepper motor can be used where there is a need to move at particular angle. So, let's get started with Stepper Motor Direction Control using Arduino:

Stepper Motor Direction Control using Arduino

In this tutorial we will learn how to make a program for Stepper Motor Direction Control using Arduino by sending dfferent commands from the serial port. First of all, I am going share the list of components used for this mini project.
  • Arduino UNO
  • Stepper motor (6 wire)
  • L298 Motor Controller (H-Bridge)
  • Voltage Regulator (7805)
  • 1000uF
  • Jumper Wires
  • Solderig Iron
  • Soldering Wire
I want to tell you a bit about the stepper motor because all the other components are discussed in detail in DC Motor Direction Control using Arduino.
Stepper Motor
Basically, stepper motors are like the DC motors that rotate in discrete steps. They have multiple arranged coils and they are usually known as phases. Motor will rotate one step at a time if we energize each phase sequence. High levels of precision can be achieved by controlling the stepper motor with computer. Steppers motors are available in the market in many different sizes. The speed of the stepper motor is controlled by frequency of pulses generated. They have wide range of applications like hard disk drives, robotics, telescope, antenna, toys etc. A six wire stepper motor is shown in the figure below.  
  • You can download complete source code for Stepper Motor Direction Control using Arduino by clicking the below button:

Download Arduino Source Code

Selection of Wires
  • I have used 6 wire stepper motor and each wire has its own function.
  • I have first divided these six wires into two pair.
  • Each pair is consisting of three wires out of which one wire is common and the other two generate pulses.
  • The two pair of three wires are shown in the figure below.

  • Then, I have chosen a common wire in each pair from which the resistance to the other two wires is common.
  • I have checked the resistance from the common wire to the both of the other wires of the same pair.
  • I found that the resistance from the common wire to both of the other wires is same.
  • We can see in the figure above the blue, pink and white wires belong to the same pair out of which white is a common wire.
  • Here is the screen shot of the figure when I found the resistance between white and blue wire and I found it to be 8.0 ohms.
  • The screen shot of the above steps is shown in the figure below.
  • After that. I checked the resistance between white and pink wire and found it to be 8.1 which is almost the same as 8.0 so, this shows that the white wire is common to both of the blue and pink wire.
  • Here is the screen shot of the above step.
  • Then I found the resistance between pink and blue wire and it was 15.6 which is exactly the double of the earlier resistance.
  • It is shown in the figure below.
  • I have connect the both common wires as shown in the figure below.

  • Here's the video in which I have discussed it in detail How to identify the wires of Stepper Motor:
  • The remaining four wires are used to generate pulses which are also know as steps
  • I have connected theses four wires to the output pins OUT1, OUT2, OUT3 and OUT4 of the L298 micro controller.
  • Input pins of L298 micro controller In1, In2, In3 and In4 are connected to the pin no 7, 6, 5 and of the Arduino UNO's board respectively.
Note:

I have also controlled the stepper motor using PIC micro controller so I would suggest all of you to first go through that tutorial before going into the details of this tutorial.

Block Diagram
  • I have made a simple block diagram for Stepper Motor Direction Control using Arduino, which will be helpful to clearly understand the algorithm and the assembling of the components of Stepper Motor Direction Control using Arduino.
  • The screenshot of the block diagram is shown in the figure below.
  • First of all we need a power supply to run the project properly.
  • Arduino reads the commands from the serial port and sends to the L298 motor driver to rotate the stepper motor.
  • The commands got printed on the LCD (Liquid Crystal Display).
Arduino Source Code Description
  • The main function of the Stepper Motor Direction Control using Arduino is given below.
#include <LiquidCrystal.h>//Library for LCD
#include <Stepper.h> //Library for Stepper motor

const int stepsPerRevolution = 255;  

// initialize the stepper library on pins
Stepper myStepper(stepsPerRevolution, 4, 5, 6, 7);
char data;
//LCD pins assigning
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
void setup() {
  // set the speed at 60 rpm
  myStepper.setSpeed(60);
  // initialize the serial port:
  Serial.begin(9600);

lcd.begin(20, 4);//LCD type

lcd.setCursor(3,0);//setting LCD cursor and printing on it
lcd.print("Stepper Motor");
lcd.setCursor(5,1);
lcd.print("Direction");
lcd.setCursor(5,2);
lcd.print("Control");
lcd.setCursor(2,3);
lcd.print("via Arduino UNO");

delay(3000);

lcd.clear ();//Clearing the LCD screen

lcd.setCursor(0,2);
lcd.print("www.TheEngineering");
lcd.setCursor(4,3);
lcd.print("Projects.com");
}

void loop() {
  if(Serial.available())
  {
    data = Serial.read(); //Reading the data from serial port
  }
  
    if(data == 'C'){Clockwise();}//Clockwise rotation
    if(data == 'A'){AntiClockwise();}//Anti-clockwise rotation
    if(data == 'S')//stopping the stepper motor
    {
      data = 0; 
      lcd.setCursor(3,0);
      lcd.print("No rotation");}
    
}
  • In the code given above we have first initialized the LCD and Stepper motor libraries.
  • Then, I assigned stepper motor pins at which it is connected to the Arduino.
  • After that I initialized the LCD pins at which it is connected to Arduino UNO.
  • Then I have made three different if statements, for the clockwise, for the anti clockwise rotation and for the no rotation.
  • Then in the loop I called clock wise and anti clockwise functions whose source code will be give and explained below.
  • Then, I cleared the serial data in order to stop the rotation of the motor.
  • The source code of the clockwise function is given below.
void Clockwise()//function for clockwise rotation
{
    Serial.println("clockwise"); //printing on the serial port
    Serial.println("");//prints blank line on the serial port
    myStepper.step(stepsPerRevolution);//counter clockwise rotation
    lcd.setCursor(3,0);//setting LCD cursor
    lcd.print("Clockwise"); //printing on LCDa
}
  • The source code for the anti clockwise function is given below.
void AntiClockwise()//function for anti clockwise rotation
{
  Serial.println("anti-clockwise");//print on the serial
  Serial.println("");//prints a blank line on the serial
  myStepper.step(-stepsPerRevolution);//clockwise movement
  lcd.setCursor(3,0);//setting LCD cursor
  lcd.print("Anti-clockwise");//printing on LCD
}
  • Now, open your Arduino software, just copy and paste the source code given above.
  • Run the program and open the Serial Port at the top right of the Arduino software.
  • Now, when you enter the command stepper motor will start running in clockwise direction.
  • If you send the command through the serial port stepper motor will start to rotate in counter clockwise direction.
  • If you send the command the rotation of the stepper motor will be stopped.
Actual Hardware Setup
  • The actual hardware operating setup for Stepper Motor Direction Control using Arduino is given in the figure below:
  • Now, if you send the command  through the serial port the stepper motor will start to rotate in clockwise direction and the command will also be printed on the LCD.
  • The screenshot of the printed command on LCD is shown in the figure below.
  • Now, if you send the command  through the serial port the stepper motor will start to rotate in anti clockwise direction and the command will also be printed on the LCD.
  • The screenshot of the printed command on LCD is shown in the figure below.
  • Now, if you send the command  through the serial port the stepper motor will show no more rotation and the command will also be printed on the LCD.
  • The screenshot of the printed command on LCD is shown in the figure below.
  • Here's the complete video demonstration of Stepper Motor Direction Control using Arduino, I hope it will help as well:
That's all from the tutorial Stepper Motor Direction Control using Arduino. I hope you enjoyed this tutorial. If you face any sort of problem, you can ask me anytime without feeling any kind of hesitation. I will try my level best to solve your problem in a better way if possible. I will explore Arduino by making different projects on it. Till then, Take care :)

DC Motor Speed Control using Arduino

Hello friends! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about how can you make a simple program for DC Motor Speed Control using Arduino UNO. In my previous tutorial, DC Motor Direction Control using Arduino, I have just controlled the DC motor in both directions at constant speed using Arduino. I have also performed the DC Motor Direction Control in Matlab by sending different commands through serial port from Matlab and LabVIEW to the Arduino and then controlled the direction of rotation of DC motor. But in this tutorial I will rotate the same DC motor at variable speed in both clockwise and anti clockwise directions. In my previous tutorial, we have seen that input pins In1 In2 of motor control driver L298 (H-Bridge) are useful to control the direction of rotation of the DC motor. In this tutorial, I have controlled its speed as well by providing different voltage levels at the enable pin of the DC motor control driver L298. It will be helpful to vary the speed of the DC motor in either clockwise or in anti clockwise direction. So, let's get started with DC Motor Speed Control using Arduino UNO:

DC Motor Speed Control using Arduino UNO

In this tutorial we will learn that how to make an algorithm for DC Motor Speed Control using Arduino UNO. Speed control of any motor is always done y Pulse Width Modulation, abbreviated as PWM. PWM pulse can be generated using Arduino and L298 Enable Pin is used to get that PWM pulse and then it controls the motor speed accordingly. Before going into the further details I would like to tell you about the concept of PWM for controlling DC motor. Moreover, you can download the complete Arduino code for DC Motor Speed Control using Arduino by clicking the below button: Download Arduino Source Code
Pulse Width Modulation (PWM)
PWM stands for Pulse Width Modulation. It basically describes the type of the digital signal. PWM technique is an excellent technique to control the analog circuits with microcontroller's digital PWM output. In this technique we can get analog results with the digital means. Digital control is used to create square wave. This pattern can vary voltages between full on i.e. 5V and full off i.e. 0V. The duration of on time i.e. when the the signal is present is known as pulse width. PWM waves for the different duty cycles are shown in the figure below. Duty cycle is basically the proportion of the time during which a system is operated. It can be expressed as a percentage. For example motor rotates for 1 second out of 100 seconds, it duty cycle can be represented as 1/100 or as 1%. For Arduino software coding the command analogWrite(255) shows the maximum i.e. 100% duty cycle. To achieve 50% duty cycle we have to update this command to analogWrite(127). Arduino UNO's pin no 3, 5, 6,10 and 11 are used as PWM pins. In this project we can control the speed of the DC motor by providing high and low voltages to the enable pin of the motor control driver L298. For example, if a motor rotates with the maximum speed and 100% duty cycle at 12V and we provide it with the 6V then it will rotate with the half of the initial speed having 50% duty cycle.
Motor Controller L298
The pins EnA and EnB of the motor controller L298 are used as the PWM pins. We can rotate the DC motor at different speed providing different high and low voltage levels to these pins of the motor control driver. If we start to reduce the maximum voltage at which the motor rotates at maximum speed, the speed of the motor also starts to reduce. In this way these enable pins are helpful to control the speed of the DC motor.
Algorithm design and descrition
In this section of the tutorial DC Motor Speed Control using Arduino UNO, I am going to explain you about designing as well as a detailed description of the designed algorithm. I will tell you about the entire algorithm in step by step procedure. Note:Since you are working on the DC motor so you must also have a look at my previous tutorials, they will be helpful for you to simulate this project as well. Open your Arduino software, copy and paste the source code given below in your software.
#include <LiquidCrystal.h>
//Keyboard Controls:
//
// C - Clockwise
// S - Stop
// A - Anti-clockwise

// Declare L298N Controller pins
// Motor 1
int count=255;
int dir1PinA = 2;
int dir2PinA = 5;
int speedPinA = 6; // PWM control
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

void setup() { 
 
Serial.begin(9600); // baud rate

lcd.begin(20, 4);
lcd.setCursor(5,0);
lcd.print("DC Motor");
lcd.setCursor(5,1);
lcd.print("Direction");
lcd.setCursor(5,2);
lcd.print("Control");
lcd.setCursor(2,3);
lcd.print("via Arduino UNO");

delay(3000);

lcd.clear ();

lcd.setCursor(0,2);
lcd.print("www.TheEngineering");
lcd.setCursor(4,3);
lcd.print("Projects.com");
//Define L298N Dual H-Bridge Motor Controller Pins

pinMode(dir1PinA,OUTPUT);
pinMode(dir2PinA,OUTPUT);
pinMode(speedPinA,OUTPUT);

analogWrite(speedPinA, 255);//Sets speed variable via PWM 

}

void loop() {

// Initialize the Serial interface:

if (Serial.available() > 0) {
int inByte = Serial.read();
int speed; // Local variable

switch (inByte) {

case 'C': // Clockwise rotation
//analogWrite(speedPinA, 255);//Sets speed variable via PWM 
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, HIGH);
Serial.println("Clockwise rotation"); // Prints out “Motor 1 Forward” on the serial monitor
Serial.println("   "); // Creates a blank line printed on the serial monitor
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("Clockwise rotation");
break;

case 'S': // No rotation
//analogWrite(speedPinA, 0); // 0 PWM (Speed)
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, LOW);
Serial.println("No rotation");
Serial.println("   ");
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("No rotation");
break;

case 'H': //Accelrating motor
count=count+20;
  if (count>255)
  {
  count =255;
  }
  analogWrite(speedPinA,count);
  delay(50);

//digitalWrite(dir1PinA, LOW);
//digitalWrite(dir2PinA, HIGH);
Serial.println("Motor is accelrating slowly");
Serial.println("   ");
Serial.println(count);
lcd.setCursor(0,0);
lcd.print("Motor is accelrating");
break;

case 'L': //Deaccelrating motor
count=count-20;
  if (count<20)
  {
  count=20;
  }
  analogWrite(speedPinA,count);
  delay(50);

//digitalWrite(dir1PinA, LOW);
//digitalWrite(dir2PinA, HIGH);
Serial.println("Motor is deaccelrating slowly");
Serial.println("   ");
Serial.println(count);
lcd.setCursor(0,0);
lcd.print("Motor Deaccelrates");
break;

case 'A': // Anti-clockwise rotation
//analogWrite(speedPinA, 255); // Maximum PWM (speed)
digitalWrite(dir1PinA, HIGH);
digitalWrite(dir2PinA, LOW);
Serial.println("Anti-clockwise rotation");
Serial.println("   ");
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("Anti-clockwise");
break;

default:
// Turn off the motor if any other key is being pressed
for (int thisPin = 2; thisPin < 11; thisPin++) {
digitalWrite(thisPin, LOW);
}
Serial.println("Wrong key is pressed");
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("Wrong key is pressed");
  }
    }
      }
  • In the previous tutorials, DC Motor Direction Control using Arduino and DC Motor Direction Control using Matlab we have learnt that how to control the direction of the DC motor.
  • We used the commands C, A and S for the clockwise rotation, anti clockwise rotation and stopping the motor respectively.
  • In this tutorial, we have added two further commands and for accelerating and de-accelerating the DC motor.
  • If we send the command H different times consecutively the speed of the motor will increase continuously.
  • If we send the command different times consecutively, the speed of the motor will start to decrease.
  • Now, upload the source code to your Arduino UNO's board.
  • Open the serial monitor at the top right of the Arduino Software.
  • And enter the commands in serial monitor periodically as explained above.
Actual Hardware Setup
  • When we enter the command in the serial monitor of the Arduino software. Motor will start rotating in the clockwise direction and a statement Clockwise rotation will be printed on serial port.
  • The same statement will be printed on the LCD as well as shown in the figure below.
  • When we enter the command in the serial monitor of the Arduino software. Motor will start rotating in the anti clockwise direction and a statement Anti clockwise rotation will be printed on serial port.
  • The same statement will be printed on the LCD as well as shown in the figure below.
  • When we enter the command in the serial monitor of the Arduino software. Motor will start accelerating and a statement Motor is accelerating will be printed on serial port.
  • The same statement will be printed on the LCD as well as shown in the figure below.
  • When we enter the command in the serial monitor of the Arduino software. Motor will start to deaccelerate and a statement Motor Deaccelerates will be printed on serial port.
  • The same statement will be printed on the LCD as well as shown in the figure below.
Thats all from the tutorial DC Motor Speed Control using Arduino UNO. I hope you have enjoyed this tutorial. If you face any sort of problem, you can ask me anytime without feeling any kind of hesitation. I will further explore my knowledge about Arduino projects in my later tutorials. Till then, Take care :)
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir