How to use Escape Sequence in C++

In today's tutorials, we are going to have a look at escape sequence in C++. In our previous tutorial, Introduction to C++ we have designed a small Hello World program and if you haven't studied it yet then you should first check that one out as I am gonna take it further from there.

In that tutorial, we have designed a code which prints the Hello world on the output screen. The code used for printing it on the output screen is as follows:

How to use Escape Sequence in C++ ??

  • Now, suppose if I want to print out "Hello World" , instead of Hello World.
  • In simple words, I wanna add "" these symbols as well on each side of Hello World.
  • But if you add them in the above program then it will generate errors.
  • So, what to do now ? Here comes the benefit of escape sequence in c++.
  • The escape sequence used to print "" these symbols in output is this symbols which is also know as back slash.
  • So, now by using this escape sequence, the code will look like something as shown below:
#include <iostream>
 
using namespace std;
 
int main(void)
{
     cout<<""Hello World!!!""<<endl;
     return 0;
}
  • Now in this way we can quite easily print the "Hello World" on the screen.
  • Now suppose you want to print itself then again what you need to do is to write two back slashes like this .
  • The first back slash is the escape sequence while the second one will print as it is.
  • There are many other uses of this back slash like if we add n after this escape sequence then it will work as a new line so instead of using this endl, we can use n as shown in below code:
#include <iostream>
 
using namespace std;
 
int main(void)
{
     cout<<""Hello World!!!"n";
     return 0;
}
  • Now you can see in the above code I have used n and removed the endl and still it will work the same.
  • Now if you want to and a TAB in the output then you can use t.
  • So, there are many benefits of this escape sequence in c++.
  • Similarly r is used for carriage return.
  • v is used for vertical tab.
  • b is used for backspace.
These are different escape sequence uses in C++ and I hope you have got it now that How to use Escape sequence in c++. In the coming tutorial, I will explain How and why to use comments in C++. That's all for today, take care and have fun !!! :)

Introduction to C++

Hello friends, hope you all are fine and having fun with your lives. Today, I am going to start a new series of tutorials on C++ Programming. and here's my first tutorial in this series which is Introduction to C++. I am gonna share a lot of tutorials in this series in future, in which I am gonna explain all about C++. In the initials tutorials, we will cover the basics of C++ Programming and later on we will also cover the pro concepts of C++ Programming.

I am planning on posting around 20 to 30 tutorials in this C++ Programming series, and I am quite sure that it will cover all about C++ and if you are a new learner then it will help you quite a lot.. I have started this series on a request of one of my readers. He suggested me this idea and I like it quite a lot so I though to pursue it. So, today let's have a look at Introduction to C++, which is quite essential when you are learning a new language you must have its introduction first.

Introduction to C++

  • So, now let me first write a simple C++ code, which is gonna print Hello World on the screen.
  • Below is given the very basic C++ code and I am gonna explain this code below to give an Introduction to C++ in detail:
#include <iostream>

using namespace std;

int main(void)
{
     cout<<"Hello World!!!"<<endl;
     return 0;
}
  • The above code is the simplest C++ code which is gonna print Hello World on the screen.
  • If you read the above code from start then you can see the first statement in the above code is #include <iostream>.
  • This first statement is actually including a library in our code file.
  • The C++ Compiler already has a lot of libraries in it which we use in our program and can get benefit out of it.
  • So, now question is what are these libraries. In any compiler the libraries are designed to create functions and then you can use these functions quite easily.
  • Let me explain it in a simple way. For example you want to add two numbers 2 + 2, now you know that the operator + is used for addition but the C++ won't know about it unless you add the library for math.
  • So, here we want to print something on our screen so the C++ will not print it on the screen unless we include this iostream library in it.
  • There are many builtin libraries for C++ like conio, arithmetic etc. which we will cover in later tutorials.
  • But for rite now, I think you have got the idea what is library, and you really don't need to know what they are doing. :)
  • Next line used is using namespace std, its a namespace standard library and you just have to add it as it is in the C++ Library.
  • Now next we have the int main(void) command. Its basically a function, which is called the main function.
  • In C++ the compiler works top to bottom and the first thing it goes into is the main function so your code must have the main function otherwise it will generate error.
  • This Main function is of the form as shown below:
int main(void)
{
  
}
  • Now in this main function, you can add anything you wanna add or execute.
  • We can create many functions in C++ coding which we will surely cover in coming tutorials but the Main function will always remain single means you can't add another Main function in it.
  • Now after the Main function, we have added a line whose initials are cout, its a c++ commands which is used to print something out and you can see rite after cout we have written a string "Hello World!!!".
  • So, because of cout command our code is printing this Hello World on the screen.
  • If you notice we have << these signs between cout and our string to print.
  • These signs are called insertion operators.
  • At the end of this statement we have endl, which is called end line, and its similar to pressing enter button and after it we have our semi colon (;). Semi colon tells the C++ that our statement is ended.
  • So, as a whole its called a statement, and in this statement we first printed out Hello World!!! and then we Entered and finally we added a semi colon to tell our program that statement has ended.
  • Now in the next statement we have return 0; , it will return nothing back and will just stop.
  • So, in our simple above program we have Main function with two statements and its printing Hello World on the screen.
  • It was kind of an Introduction to C++ in which we have designed a small program and then discussed it.
So, that's all about the introduction to C++, and I hope you guys have learned something out of it. In the coming tutorials, I am gonna post more about C++ and we will cover about variable used in it and how we can make complex codes on c++. So stay tuned and have fun !!! :)

Arduino Vs Raspberry Pi

Hello friends, I hope you all are fine and enjoying your lives. Today, I am going to share a comparison titled Arduino Vs Raspberry Pi. Actually, I have been receiving a lot of emails and comments from new engineering students that "we are new in embedded and we want to start our project so please tell us which one is better Arduino or Raspberry Pi?" So, I thought to write a post on Arduino Vs Raspberry Pi and in this post, I am going to make a detailed comparison between the two and will let you know, which one you should use in your project and why?

So, I hope that you are all aware of or at least have heard about these two boards, which are Arduino and Raspberry Pi. If you haven't heard yet then you must have a look at Arduino Official Site and Raspberry Pi Official Site. They will give you a basic overview of what these boards are. Anyhow, I am going to start it from the very basics so that you guys won't get into much trouble. So, let's get started with Arduino Vs Raspberry Pi:

Where To Buy?
No.ComponentsDistributorLink To Buy
1Arduino Mega 2560AmazonBuy Now
2Arduino NanoAmazonBuy Now
3Arduino Pro MiniAmazonBuy Now
4Arduino UnoAmazonBuy Now
5Raspberry Pi 3AmazonBuy Now
6Raspberry Pi 4AmazonBuy Now
7Raspberry Pi PicoAmazonBuy Now
8Raspberry Pi ZeroAmazonBuy Now

Arduino Vs Raspberry Pi

I have created few points below and in each of these points, I have made the difference between these two boards. I have also mentioned their strengths and weaknesses and which one to use. Obviously, they both have their own importance so we can't say that one is better than the other. Instead, we are making a comparison between the two and then you will get a clear idea of which one you should use for your project. The selection of your controller board actually depends entirely on the nature of your project. Am I getting far :O don't worry if it's more to digest about Arduino Uno R3 Vs Raspberry PI 3, I am explaining them below in detail. :D

1. History

Arduino:

  • The idea of Arduino was first presented by Massimo Banzi in Italy. That's why it's written Made in Italy on each of these boards. :)
  • Banzi was a teacher at Interaction Design Institute Ivrea and the reason for designing these boards was to help his students by giving them an easy-to-use platform.
  • So that, students don't waste much time over soldering etc and spend more time in designing the algorithms.
Raspberry Pi:
  • Raspberry Pi was first invented by Eben Upton in the United Kingdom.
  • He was also a teacher and he has the same reason for developing these boards.
  • He also wanted to help his students so that they learn more out of it.
  • Upton was a Professor at the University of Cambridge.
Obviously, they both have co-founders, who have helped them a lot in bringing these ideas to existence. So, let's move on to the next step of this Arduino Vs Raspberry Pi comparison.

2. Nature of Arduino & Raspberry Pi

Arduino:
  • The Arduino boards are actually Microcontrollers boards but in a very easy-to-use form.
  • Have you ever worked on PIC Microcontroller, Atmel or 8051 Microcontroller?
  • If you have worked on standalone microcontrollers, you must be aware of Microcontroller basic circuit, which includes crystal oscillator and pull-up resistors, capacitors etc.
  • Moreover, you also need the programmer/burner hardware using which you upload your code into these microcontrollers.
  • But in Arduino, you don't need to use any of these. Arduino comes with a built-in programmer and an onboard basic circuit for powering up the microcontroller.
  • So, what you need to do is simply plug Arduino board and start testing your code.
  • So, in simple words, Arduino is nothing but a simple microcontroller board.
Raspberry Pi:
  • Now if we talk about Raspberry Pi, it's a mini-computer and is actually termed a microprocessor.
  • Raspberry Pi has onboard RAM, ROM, i/O Ports, USB Ports, HDMI Port etc.
  • Seems quite powerful than Arduino but don't come to a conclusion right away :)
  • But yes Raspberry Pi is like a small computer, obviously, it's not comparable with your Laptop or PC but it's really powerful.
  • And the beauty of it lies in the small size and low price.
  • The latest Raspberry Pi even has a RAM of around 3GB, which is quite a lot. I am using Note 3 Mobile and it has 3GB RAM. So, now you can get an idea of what it is capable of.
  • As it's a small computer so you must be thinking what its operating system. When it comes out of the factory, it has no operating system on it but one can install any operating system like Linux, Windows etc.
  • Normally it is used with Linux and its current operating system is called Raspbian.
So, from the above discussion, we concluded that Arduino is a Microcontroller board while Raspberry Pi is a mini-computer. Next, we are going to have a look at the type of Arduino Vs Raspberry Pi.

3. Types of Arduino Vs Raspberry Pi

Arduino:
  • The first board developed by the Arduino company was Arduino UNO which uses Atmega328 Microcontroller but later on, they have developed many new boards.
  • For example, now we have Arduino Ethernet Shield, Arduino Wifi Shield using these we can provide Internet access to our system.
  • Recently they have also developed the Arduino YUN board, which also supports Linux just like Raspberry Pi.
  • Arduino Due is another board that works on a 32-bit instruction set.
  • So, in short, there are a lot of Arduino boards and by combining different boards you can accomplish anything.
  • Suppose, you want to control your Fan via Wifi then you can use Arduino UNO with Arduino Wifi shield and you can easily design this IoT project and can control the fan over WiFi.
Raspberry Pi:
  • Raspberry Pi doesn't have different boards for different tasks like Arduino.
  • Like once there was Raspberry Pi Model A but then they added some more functionality like increased the RAM end so we have Raspberry Pi 2, Raspberry Pi 3 Raspberry Pi 4 etc.
  • So, you can think of Raspberry Pi as a mobile, whose models come out with more enhancement.
  • As I told you earlier Raspberry Pi is a small computer board so it already has everything in it like Wifi, Ethernet, USB Host etc.
  • Raspberry Pi has recently launched a Microcontroller board called Raspberry Pi Pico, which is available for $4.

4. Programming Code

Arduino:
  • For programming Arduino boards, Arduino has launched official software called Arduino IDE.
  • Arduino uses C programming language with a slight difference in syntax from the original C.
  • It has an extensive list of libraries(mostly third-party) for interfacing sensors and modules.
Raspberry Pi:
  • Raspberry Pi can be programmed in any high-level programming language i.e. python, C# etc.
  • Normally, python is used for programming purposes.

Arduino Vs Raspberry Pi - Which one you should prefer?

For a new Engineering student, who has just started his project. He always wonders which one I should use among these two. Should I go with Arduino or should I start working on Raspberry Pi? It's really a big question if you are new in this field. So, let me tell you one thing first, no one is better than the other, Arduino and Raspberry Pi both have their own importance. Now which one you should use, entirely depends on the nature of your project. So, let's take a look at projects for both of these boards. I think this Arduino Vs Raspberry Pi comparison is now going to take an interesting turn. :)

Arduino:
  • Whenever you are working on some pure hardware-related project, in which you need to use different sensors, need to move your motors or actuators etc. then you should always go for Arduino because Arduino is a microcontroller and its best for hardware equipment controlling.
  • That's why in most of the Electrical, Electronics, Mechatronics and Mechanical Projects, Arduino is preferred.
  • It's not like you can't control sensors or motors on Raspberry Pi but it's too difficult in Raspberry Pi and quite easy in Arduino.
  • Moreover, with Arduino, you can attach as many sensors as you want. In simple words, Arduino has a lot of I/Os.
  • Once I have to work on a project, in which I have to control fifty relays so in that case I have used Arduino Mega 2560 which has around 60 input/Output Pins.
  • But you can't control fifty relays with Raspberry Pi.
  • So, in all the hardware projects where you don't need to do cloud computing, IoT etc. it's always preferred to use Arduino boards.
Raspberry Pi:
  • Raspberry Pi is mostly used in computer software projects i.e. IoT, cloud computing etc.
  • Like you have a project in which you need to send data over to some network, then in these types of projects, your first choice should be Raspberry Pi.
  • I once had a project in which I have to design an online Home Automation system.
  • So, in such projects, we just need to interface few sensors which we can do with the Raspberry Pi as it has few Input/Output Pins.
  • But the main part of such projects is to send sensors data over to some network so Raspberry Pi is the right choice here.
  • Although we can also use Arduino YUN in such projects as well but because Raspberry Pi is programmed in python so it's more flexible to use when it comes to cloud computing.
  • Similarly, if you want to design some Face recognition project then Raspberry Pi comes in handy because we can easily install openCV on it as it's an OS (LINUX), we can install anything we want.

So, that's a kind of an overview on Arduino Vs Raspberry Pi, which I think you guys must have enjoyed. It was quite boring so that's why I have tried my best to make it as interesting as I can, but still, if you find it boring then I can't do anything. :) So, that's all about Arduino Vs Raspberry Pi, I hope you guys have got something out of it. Will see you guys in the next tutorial. Till then take care and have fun. :)

How to Install and Download Proteus Software

Hello everyone, I hope you all are fine and having fun. Today, I am not going to share a project. Instead, I am gonna share a tutorial in which I will teach you How to download Proteus and install it. It's going to be a quick tutorial because there's not much in it to say. You know Proteus is a Paid software and you must pay the company because they have put really great effort into designing this software. So, if you can afford then you must buy the latest version of Proteus software from their Official Website.

In today's post, I am going to share the Full version of Proteus software and it is Proteus 7 Professional, I am sharing it for engineering students. I hope you are going to enjoy this software its not only free but also complete and the Professional version. So, let's get started with How to Install and Download Proteus Software. Please watch this youTube video for better guidance:

How to Install and Download Proteus Software ???

  • First of all, download the Proteus 7 Professional software by clicking the below button:
Proteus 7 Professional Free download Proteus 8.5 Professional Free download

  • Once you downloaded the files, now unrar them and place them in some folder.
  • The next thing you need to do is to run the Setup file from the package and it will start to install.
  • Use the recommended settings and once it's done then it will ask about the key.
  • The default key is given in the package so browse it and upload it to the software.
  • Once the key is uploaded, now complete the setup and you will get yourself a Proteus software.
  • After the completion, one more thing you need to do is to install the software given in the next folder.
  • In the path selection, gave it the path to your Proteus software, which you just installed.
  • Now hit run and after it's complete, your Proteus will become registered.
  • I have made a small video that will explain the above procedure of How to Install and Download Proteus software in a better way.
So, that's all for today, I hope you guys are gonna enjoy this Proteus software free download and gonna write about it in the comments. That's all for today, will meet you guys in the next tutorial. Till then take care !!! :)

DTMF Decoder using MATLAB

Hello friends, hope you all are fine and having fun with your lives. Today, I am going to share a project named as DTMF Decoder using MATLAB. In this project, I have designed a keypad in MATLAB using the GUI functionality of MATLAB. After designing the keypad, I have assigned a tune to each of these buttons. Obviously the tune attached to each button is different and when we press any of these buttons, then the MATLAB recognizes the respective button.

This project is designed in MATLAB and I have tested it on MATLAB 2009 and MATLAB 2014 and it works fine on both of them. Code is given below in this tutorial for download. f you got problem in it then ask in comments and I will try to resolve them. So, let's get started with DTMF decoder in MATLAB.

DTMF Decoder using MATLAB

  • You can download the complete code by clicking the below button:
Download Project Files

  • In this download package, you will get three files and you need to run the file named as decoder.m.
  • When you run the file named as decoder.m, it will start the GUI which will look something as shown in below figure:
  • That's the GUI used for DTMF Decoder using MATLAB.
  • You can see a keypad is shown in the above GUI, now I have assigned a specific tune to each of these buttons and the code for assigning this tune is as follows:
t=[0:0.000125:.05];
fs=8000;
f1=770;f2=1477;
y1=.25*sin(2*pi*f1*t);
y2=.25*sin(2*pi*f2*t);
y=y1+y2;sound(y,fs)
  • So, you can see in the above code that I have generated a sine wave and then created a sound using that sine wave.
  • So, we have such sounds assigned to each of these buttons.
  • Now once button is pressed, the respective sound will be activated and rite after that sound, I have added a subroutine for decoding that sound.
  • This subroutine is placed in a separate file named as subdecode.m.
  • This subdecode.m is responsible for DTMF decoding and its code is as follows:
axes(handles.fig1);
plot(t,y);
set(handles.fig1,'XMinorTick','on');
title('DTMF Input');xlabel('Time');
ylabel('Amplitude');grid;

rmain=2048*2;rmag=1024*2;
cn=9;cr=0.5;
cl=.25;ch=.28;
[b,a]=cheby1(cn,cr,cl);
yfilt1=filter(b,a,y);
h2=fft(yfilt1,rmain);
hmag2=abs(h2(1:rmag));
[b1,a1]=cheby1(cn,cr,ch,'high');
yfilt2=filter(b1,a1,y);
h3=fft(yfilt2,rmain);
hmag3=abs(h3(1:rmag));

axes(handles.fig2);
plot(yfilt1);grid;
title('Filtered Low Freq. Signal');
xlabel('Time');ylabel('Amplitude');

axes(handles.fig3);
plot(yfilt2);grid;
title('Filtered High Freq. Signal');
xlabel('Time');ylabel('Amplitude');

hlow=fft(yfilt1,rmain);
hmaglow=abs(hlow);
axes(handles.fig4);
plot(hmaglow(1:rmag));
title('FFT Low Pass');grid;
xlabel('Time');ylabel('Amplitude');

hhigh=fft(yfilt2,rmain);
hmaghigh=abs(hhigh);
axes(handles.fig5);
plot(hmaghigh(1:rmag));
title('FFT High Pass');grid;
xlabel('Time');ylabel('Amplitude');

m=max(abs(hmag2));n=max(abs(hmag3));
o=find(m==hmag2);p=find(n==hmag3);
j=((o-1)*fs)/rmain;
k=((p-1)*fs)/rmain;

if j<=732.59 & k<=1270.91;
   disp('---> Key Pressed is 1');
   elseif j<=732.59 & k<=1404.73;
      disp('---> Key Pressed is 2');
   elseif j<=732.59 & k<=1553.04;
      disp('---> Key Pressed is 3');
   elseif j<=732.59 & k>1553.05;
      disp('---> Key Pressed is A');
   elseif j<=809.96 & k<=1270.91;   
      disp('---> Key Pressed is 4');
   elseif j<=809.96 & k<=1404.73;
      disp('---> Key Pressed is 5');
   elseif j<=809.96 & k<=1553.04;
      disp('---> Key Pressed is 6');   
   elseif j<=809.96 & k>1553.05;
      disp('---> Key Pressed is B');  
   elseif j<=895.39 & k<=1270.91;
      disp('---> Key Pressed is 7');
   elseif j<=895.39 & k<=1404.73;
      disp('---> Key Pressed is 8');
   elseif j<=895.39 & k<=1553.04;
      disp('---> Key Pressed is 9');
   elseif j<=895.39 & k>1553.05;      
      disp('---> Key Pressed is C');   
   elseif j>895.40 & k<=1270.91;   
      disp('---> Key Pressed is *');
   elseif j>895.40 & k<=1404.73;  
      disp('---> Key Pressed is 0');
   elseif j>895.40 & k<=1553.04;  
      disp('---> Key Pressed is #');
   elseif j>895.40 & k>1553.05;  
      disp('---> Key Pressed is D');
end
  • Now you can see in this code we are applying FFT on each of these sound signals and then comparing them to get our required button press.
  • Now, when I press any of these buttons then the GUI will look something as shown in below figure:
  • You can see in the above figure that first graph is showing the DTMF input, which is actual signal which I have converted to sound on button press.
  • The second graph is showing the Filtered Low Frequency Signal while the third one is showing the Filtered High Frequency Signal.
  • The two graphs on the right side are showing the Amplitude of FFT Low Pass and FFT High Pass.
  • Now if you have a look at the Command window of MATLAB then it will give you the button pressed as shown in below figure:
  • These are the buttons which I have pressed while testing it and it has given me each time which button is pressed.
  • Here's the video which will give you better idea of How this DTMF decoder using MATLAB is working.
That's all about DTMF Decoder using MATLAB. If you have any questions, then ask in comments and I will try my best to resolve them. Till next tutorial take care and have fun !!! :)

PLC Projects

Hello friends, hope you all are having fun with your lives. Today, I am going to share links related to PLC projects. I have shared few PLC projects on my blog so here on the post I am gonna compile a list and will post all the PLC projects posted till now. I will keep on updating this list so stay tuned. All the PLC projects posted here are completely designed by our team so if you wanna copy them then you are most welcome but do mentioned the link of respective project as a favor. Its not a very big list rite now but I am gonna update more projects real soon and will update the list. So, let's get started with PLC projects:

PLC Projects

Here's the complete list of PLC projects posted till now on our blog:

Password Protection using PIC Microcontroller

Hello friends, hope you all are fine and having fun with your lives. Today, I am going to share a new project which is Password Protection using PIC Microcontroller. In this project I am going to use keypad and LCD and will be designing a system in which I am gonna drive a motor if the correct password is supplied. If you entered the wrong password then the motor will not move and you will get another chance to enter the correct password. I hope you guys are gonna enjoy this one.

I have used Keypad, LCD and PIC Microcontroller in order to design the simulation in Proteus ISIS software. You should also have a look at Electronic Door Lock using PIC Microcontroller, which is quite similar with the only difference of keypad. In that previous project, I have used serial monitor for taking inputs but in today's tutorial, I have used Keypad for taking inputs. I hope you are gonna enjoy this one.

I have used Proteus software for designing the simulation and I have used MikroC Pro for PIC compiler for designing the programming code for PIC Microcontroller and I have used PIC16F877 Microcontroller for designing this project. The code and simulation is given below for download. If you have any problem then ask in comments and I will try my best to resolve them. So, let's get started with Password Protection using PIC Microcontroller.

Password Protection using PIC Microcontroller

  • You can download the complete simulation along with the code by clicking the below button but as I always suggests that you should design it on your own so that you get most out of it:
Download Project Files

  • So, now let's design this Password Protection using PIC Microcontroller project, so design a circuit as shown in below figure:
  • You can see in the above figure that I have used LCD 20x4 along with Keypad, motor and PIC Microcontroller.
  • I have also used a transistor which is kind of a driver for DC Motor, because DC motor is operated at 12V while PIC Microcontroller signal is of 5V so we need this transistor in order to drive our motor.
Note:
  • If you want to use this new stylish LCD in your Proteus simulation then you need to download and install this New LCD Library for Proteus. All instructions are given in this link for using this LCD.
  • Next thing we need to do is to design a programming code for this project.
  • I have designed the code in MikroC Pro for PIC compiler so copy the below code and paste it in your project of MikroC Pro for PIC and compile to get the hex file:
unsigned short kp;
char actual_password[] = "123123";
char given_password[] = "000000";
int count;
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

// Keypad module connections
char  keypadPort at PORTD;
// End Keypad module connections

void Password_prompt(){
  Lcd_Cmd(_LCD_CLEAR);                     // Clear display
  Lcd_Out(1, 1, "Motor is Off");
  Lcd_Out(2,1,"and Locked");
  Delay_ms(1000);

  Lcd_Cmd(_LCD_CLEAR);                     // Clear display
  Lcd_Out(1, 1, "Enter 6 digit no:");

  Lcd_Cmd(_LCD_BLINK_CURSOR_ON);                // Cursor off
  Lcd_Cmd(_LCD_SECOND_ROW);
}

//Initialization starts here-------------------------------
void Init(){
Lcd_Init();                        // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);                     // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);                // Cursor off
  Lcd_Out(1, 1, "Welcome to");
  Lcd_Out(2, 1, "Password Lock");
  Lcd_Out(3, 2, "www.TheEngineering");
  Lcd_Out(4, 5,"Projects.com");

  Delay_ms(5000);
  Password_prompt();
  TRISB=0;

count=0;
Keypad_Init();                           // Initialize Keypad
}
//Initilization ends here----------------------------------------

//Password check routine starts here-----------------------------
int Check_password(){

Lcd_Cmd(_LCD_CLEAR);
if(!memcmp(actual_password, given_password, 6)){
 Lcd_Out(1, 1, "Password Matched");
 Lcd_Out(2,1,"Motor is on");

 return 1;
}
else{
  Lcd_Out(1, 1, "Incorrect Password");
  Lcd_Out(2, 1, "Try Again!");

  Delay_ms(2000);
  Password_prompt();
  return 0;
  //Enter_password();
  }
  count=0;
}
//Password check routine ends here-----------------------------

void main() {
      Init();
    do {
      kp = 0;                                // Reset key code variable
      if(count==6)
       {
          PORTB.B7=Check_password();    //0/1 according to password check and drives the motor
          count=0;
          if(PORTB.B7==1){
             Delay_ms(1000);
             Lcd_Cmd(_LCD_CLEAR);
             //Lcd_Cmd(_LCD_FIRST_ROW);*/
             Lcd_Out(1,1,"Press * to Off");
             Lcd_Out(2,1,"and Lock again");
             Lcd_Cmd(_LCD_CURSOR_OFF);           // Cursor off

        do
         // kp = Keypad_Key_Press();          // Store key code in kp variable
         kp = Keypad_Key_Click();             // Store key code in kp variable
        while (kp!=13);
         if(kp==13){
           PORTB.B7=0;
           Password_prompt();
          }
         }
       }
    // Wait for key to be pressed and released
      do
      // kp = Keypad_Key_Press();          // Store key code in kp variable
      kp = Keypad_Key_Click();             // Store key code in kp variable
      while (!kp);
     switch (kp) {
      case  1: kp = 49;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 1        // Uncomment this block for keypad4x4
      case  2: kp = 50;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 2
      case  3: kp = 51;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 3
      case  4: kp = 65;Lcd_Chr_Cp(kp); break; // A
      case  5: kp = 52;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 4
      case  6: kp = 53;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 5
      case  7: kp = 54;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 6
      case  8: kp = 66;Lcd_Chr_Cp(kp); break; // B
      case  9: kp = 55;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 7
      case 10: kp = 56;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 8
      case 11: kp = 57;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 9
      case 12: kp = 67;Lcd_Chr_Cp(kp); break; // C
      case 13: kp = 42;Lcd_Cmd(_LCD_MOVE_CURSOR_LEFT);count--; break; // *
      case 14: kp = 48;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 0
      case 15: kp = 35;Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);count++; break; // #
      case 16: kp = 68;Lcd_Chr_Cp(kp); break; // D

     }
    } while (1);

}
  • This code is used for design the code for this Password Protection using PIC Microcontroller project.
  • Now after getting the hex file from this code, upload it in your simulation and if everything goes fine then you will get results as shown in below figure.
  • The first screen will be look like something as shown below:
  • So, its saying Welcome to Password Lock and the the link of our blog.
  • After that it will ask for 6 digit password, as shown in below figure:
  • Now the default password for this project is 123123, so if you have given the correct password then the motor will start moving but if you given the wrong password then it wont move and will ask for password again.
  • So, let's give it a wrong password at first:
  • Now you can see in the above figure that when I have given the wrong password then it says Incorrect Password and Try again.
  • The motor will also remain stationary.
  • Now I am gonna give it a correct password and we will see the motor will start moving as shown in below figure:
  • Now when I have given the correct password, the motor started moving and the LCD says, press * to OFF and Lock again.
  • So, now when you press * then the motor will stop and it will again ask you to enter 6 digit password.
  • I have design this below video which will give you a better idea of working of this project:
So, that's all for today, I hope you have understood all about Password Protection using PIC Microcontroller. Will meet you guys in the next tutorial, till then take care and have fun !!! :)

LabView Projects

Hello friends, hope you all are fine and having fun with your lives. Today, I am going to share all the LabView Projects, posted on our blog. These LabView projects are entirely designed by the TEP team and I hope they will help you in some way. Rite now the list is quite small but I am gonna post more tutorials and projects related to LabView soon. So, keep visiting or subscribe us via email so that you get these exciting tutorials straight to your inbox.

Moreover, LabView is really a difficult software and it really took us a lot of time in designing these projects so other blogger are more than welcome to share our projects on their blog but do mention the respective link from where you copied as a favor. I am gonna share the complete list here. The benefit of doing this is that it will also organize the projects and you guys can get all of them in one place. So, anyways, let's get started with LabView Projects.

LabView Projects

First of all, you should read these basic LabView Tutorial. In these tutorial, I have given the Introduction of LabView and have explained from very basics how to start working with LabView. So, I would suggest you if you are new to LabView then read these LabView tutorials one by one:
Getting Started with LabView
Basic LabView Projects
These are the basic LabView Projects. So, if you have read the above mentioned basic LabView Tutorials then you should have a look at these basic LabView Projects:
Embedded LabView Projects
Here, I have given few Embedded LabView Projects which we have designed in our lab. These Simulations are given for download in each of these tutorials. So, if you wanna communicate with your Embedded device via LabView then you should read them:
NI myRIO Labview Projects
NI myRIO is an amazing Embedded module which is FPGa supported and is designed by National Instruments itself. I have worked on it during my projects so I have shared few tutorials on NI myRIO, which are as follows:

New LCD Library for Proteus

Update: Here's the latest version of LCD library: LCD Library for Proteus V2.0.


Hello everyone, I hope you all are fine and having fun with your lives. Today, I am going to share a new LCD Library for Proteus. We all know about LCDs, used for displaying data in embedded projects i.e. sensor values or indications etc. Proteus already have LCDs in it but they are not much good-looking. So, I designed two new LCDs in Proteus that look identical to real-world LCDs.

So, I am going to share these LCD libraries in today's post. I hope you are going to enjoy them as they will add some uniqueness to your project.

I have also used these new LCDs in different projects so if you wanna see these LCDs in action then you should have a look at LCD Interfacing with Microcontrollers. In this tutorial, I have shown how to interface it with Arduino, PIC Microcontroller and 8051 Microcontroller. So, let's get started with this New LCD Library for Proteus:

  • Here's a video explaining the above tutorial in a better form:
Note:

New LCD Library for Proteus

  • First of all, what you need to do is to download this new LCD Library for Proteus by clicking the below button:
New LCD Library for Proteus
  • In this package, you will find two files named:
    • LCDLibraryTEP.LIB
    • LCDLibraryTEP.IDX
  • Now place both of these files in the library folder of your Proteus software.
  • Now in the component search section, you need to make a search for LCDLibraryTEP or you can also search LCD 16x2 or LCD 20x4, whichever you wanna use.
  • Now you will find two components as shown in below figure:
  • Now place both of them in your workspace and they will look like something as shown in the below figure:
  • Aren't they looking more pretty now ??? :)
  • So, that was the idea to make them look more alive. They are working perfectly as I have tested them.
  • So, now let's test them with the Arduino board.
  • I am going to run a simple program from an Arduino board on both of these LCDs.
  • Let's design a simple circuit as shown in the below figure:
  • Now upload the below Arduino code in your software:
#include 

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

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.setCursor(1,0);
  lcd.print("www.TheEngineering");
  lcd.setCursor(4,1);
  lcd.print("Projects.com");
}

void loop() {
  
}
  • Now get the hex file from Arduino software and upload that hex file in your Proteus software.
  • After uploading the hex file, run your simulation and if everything goes fine then it will look like something as shown in the below figure:
  • Now you can see both are working correctly. Now you can use them like normal LCDs but with a more realistic look.

So, that's all for today. I hope you guys will enjoy this New LCD Library for Proteus. Moreover, you should have a look at this tutorial where I have used this LCD Proteus Library, named: Display ADC value on LCD using Arduino. So, will meet you guys in the next tutorial soon. Take care and have fun !!! :)

How to Measure Frequency using Arduino

Hello friends, hope you all are fine and having fun with your lives. Today, I am going to share on How to measure Frequency using Arduino board. Its quite a simple tutorial but is an essential one especially when you are working on some power related project. Because in Power projects, you have to measure the frequency of AC voltages. I was working on a project in which I have to do dimming of AC Lamp so in that project I have to measure the frequency of AC signal.

I have designed this project using Arduino UNO and have simulated in the Proteus software, which you all know is my favorite simulating software. :) The code is also quite simple which I have given below for download. The simulation is also included in download package but again I suggest you to design it on your own. If you got into any trouble then ask in comments and I will try to resolve them. Anyways let's get started with How to measure frequency using Arduino.

How to Measure Frequency using Arduino ???

  • You can download the simulation for this frequency measuring by clicking the below button:

Download Project Files

  • Now let's design this project in Proteus. So, first of all, design a simulation as shown in below figure:
  • The small block attached with the pin # 2 of Arduino is a frequency meter.
  • We can create any kind of frequency signal using this component.
  • If you double click it then its properties will open up where you can change the frequency as shown in below figure:
  • You can see in the above figure that I have setted the Clock Frequency to 2000 Hz.
  • Now, let's design the programming code for this project. So, paste the below code in your Arduino software:
#include <LiquidCrystal.h>

LiquidCrystal lcd(13,12,11,10,9,8);

long freq, tempo;
int pulsos;
boolean pulso;
void setup() {
  pulso=HIGH;
  pinMode(2,INPUT);
  lcd.begin(20, 4);
  lcd.setCursor(0,0);
  lcd.print("Frequency =");
  lcd.setCursor(1,2);
  lcd.print("www.TheEngineering");
  lcd.setCursor(4,3);
  lcd.print("Projects.com");
}

void loop() {
  tempo = millis();
  if(digitalRead(2)==HIGH)
  {
    if(pulso==HIGH)
    {
      pulsos = pulsos + 1;
    }

    pulso=LOW; 

  }
  else{
    pulso=HIGH;
  }

  if(tempo%2000==0){
    freq = pulsos/2;
    lcd.setCursor(12,0);
    lcd.print(freq);
    lcd.print("Hz");
    pulsos=0;  
  }
}
  • Now using the above code, get your hex file from Arduino software and upload it in your Proteus software.
  • Now once you are done then run your simulation and if everything goes fine then you will get results as shown in below figure:
  • Now you can see the LCD is showing the same frequency as we set in the properties of the frequency meter.
  • The code is quite simple, I don't think it needs any explanation but if you get into sme trouble then ask in comments.
  • The below video will show you this project in detail:
So, that's all for today. I hope now you know How to measure frequency using Arduino. So, will meet you guys in the next tutorial. 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