First Project in C#
Hello everyone, I hope you all are fine and having fun with your lives. Today, we are going to design our First Project in C#. In the previous tutorial, we have seen a detailed Introduction to C#, where we have studied its importance in the software world.
Today, we are going to create our first project in C#. So, let's get started with our first code in the C# Tutorial series.
First Project in C#
- I am going to use Microsoft Visual Studio 2019 Community Edition, which is free to use, and you can download it from its official website.
- There are different languages available in Visual Studio i.e. C, C++, C# and F#. C# is the most commonly used programming language among all.
- Now, I assume that you have installed Visual Studio and are ready to design your first project.
- So, open your Microsoft Visual Studio, and create a New Project by clicking File and then New Project, as shown in the figure on the right.
- You can also create a new project by clicking Ctrl+N.
- Now once you create the New Project, a new pop up window will open up, as shown in below figure:
- Now, as shown in the above figure, first of all, select the Visual C# as obviously we are gonna use the C# language in introduction to C#.
- Next, select the Windows and then Console Application.
- Next, we need to give a name to this Console Application, which I have given is MyFirstProject and finally click the OK button.
- Now in this window, we are gonna update our code in C#. Currently, it has simple Hello World code, as shown in below figure:
- Let's understand this code, line by line:
Namespace Declaration
- The first line of code is "using System", here the System is a built-in C# Namespace and we are declaring it at the top of our code.
- Currently, we are using just 1 namespace but later on, we are going to add a lot more and all these namespace declarations will come at the top of our code.
- You can think of a namespace as a library that has different classes & methods in it.
- So, when we declare it at the top, then all its classes become available to use in our code i.e. Console is a class of System namespace.
Projects Namespace
- Next, we have namespace TEPProject, which is the namespace of our newly created project, all of our classes will be placed inside this namespace.
- You can see this namespace has curly brackets { }, which has all the remaining code in them.
Program class
- When you run your code, the compiler finds the project's namespace and inside this namespace, it makes a search for a C# Class named Program and in Program class, it goes into the C# Method named Main.
- That's why we have the class Program inside our namespace TEPProject and inside this class, we have our static void Main(string[] args) function.
- This Main function is a static function and it has arguments with datatype string.
- This Main Function is the entry point of our compiler in our project, we have to write our code in this function or method. ( Functions are also called methods )
- Inside this Main function, we have simply printed Hello World to our Console.
- This Console is a member of namespace Systems, if we remove the namespace from the top then this Console will create the error.
So, now let's run our code and if everything goes fine then you will get something as shown in the below figure:
- We have Hello World printed in our console panel, it's doing nothing else.
- Moreover, if you are not getting things like C# Namespace or C# Methods etc. then no need to worry, we will cover all of them in coming tutorials in detail.
Extend C# Hello World Project
- Solution Explorer contains all files of your project and Program.cs is the actual code file in which I am going to write our code.
- So, let's add the below code in our Main function of Program.cs File:
Console.WriteLine("What are you learning ???");
string subject = Console.ReadLine();
Console.WriteLine("I am learning {0}", subject);
- Now your Program.cs file will look something as shown in the below figure:
- In the first line of code, I am printing "What are you learning ???" on the console.
- In the second line, I am waiting for incoming data from the console, which the user has to enter, and I am saving that data in a string variable called subject.
- In the third line, I am printing the data entered by the user on the Console.
- You must have noticed {0}, it's one way of adding data in a string and is called Place Holder Syntax.
- You can add as much data as you want, separated by commas, and can print them as {0} {1} {2} and so on.
- Let's run our code and we will get a similar output, as shown in the below figure:
- I have entered C# and it has printed it back, as you can see in the console.
- Now when you press any key, the console will stop.
- You can also use Concatenation instead of Place Holder Syntax, let's have a look at the third line, in below code:
- So, now I have used + sign instead of curly brackets {0}, it's called concatenating a string.
- If you run your code, you will get the same output, as shown in the above figure.
That's all for today. I hope you guys have got something out of it. In the next C# tutorial, we will have a look at
Introduction to Data Types in C#. So stay tuned and have fun !!! :)
Introduction to C# ( C Sharp )
Hello friends, I hope you all are fine and having fun. Today, I am going to start a new series on C# Programming Language and today we are gonna have a look at first tutorial Introduction to C#.
Are you planning to study C# programming language? If so, then you have come to the right place. Knowing how to develop computer software is perhaps the most crucial ability to master in the present era. Computers have now made their way into practically every business. Whether it's an airplane's automation or a motorcycle's speedometer, computer programming languages are everywhere around us. And out of all the computer programming languages out there, C# is the most preferred and ideal language to learn. But why? Do not worry. This article contains all the answers to your questions. So, keep reading!
C# is the most widely used programming language for designing software & websites. Most of the software, we use in our daily life are designed using this C# Language. So, let's get started with a detailed Introduction to C#.
Introduction to C#
- C# (pronounced see sharp) is a general-purpose programming language developed by Microsoft in 2000, as part of .NET framework.
- Microsoft Visual Studio is a Programming environment used for writing C#.
- C# was originally designed by Anders Hejlsberg, who currently works as the lead architect of C#.
C# Programming: The Language of God
C#, also known as the Language of God, is a contemporary, broad coding language that can help accomplish hundreds of activities and purposes in different fields. Microsoft designed C# and thus is typically used with the Windows .NET platform. The .NET Framework is actually a computer-developing framework that allows you to create applications for Windows, Azure, Web, and other programming platforms with programming languages including C#, Visual Basic, and F#.
C# can also be used in an open standard system. The latest iteration of C# is version 7.2 and is specifically for Standard Language Framework. It has a syntax that is identical to Java. So, if you are familiar with Java or C++, it would be a piece of cake for you. Do not worry if you are a beginner. This article is specifically for beginners so they can have a better understanding before actually studying the language.
History of C#
Unlike well-established languages like Java, Python, PHP, and others, C# is a modern entry to the computer programming community over twenty-one years ago. Microsoft's Anders Hejlsberg, a Denmark computer programmer with a record of renowned innovations, created this programming language in 2000. The programming language was released in 2002 and has benefited all of us till today.
Why Should You Learn C#?
Now, most people have this question: Why Should I Learn C# and Not Others? Well, C# is a one-of-a-kind programming language that's also user-friendly and quicker to comprehend. It has excellent functionality in the areas of efficiency and requires relatively minimal resources. C# may be used to develop a wide range of applications. Some of these are listed below:
- Windows consumer services by utilizing WPF, Windows Forms, and UWP
- Network applications
- Azure and Cloud applications
- Modules, features, and terminal applications
- Internet projects with ASP.NET Core and ASP.NET
- Compatibility, information, and connectivity technologies
- Android and iOS and Android phone applications by utilizing Xamarin
Other than developing applications, it is vital to learn C# because of three main reasons discussed below:
-
High Salaries
In today's world, everyone wants to make a fair living, and computer programmers are among the most fortunate people out there. During the pandemic, almost everyone was having a hard time except the computer programmers because they continued their programming. With other programming languages, you get good salary packages. However, if you know the C# programming language, you will get job opportunities in multinational companies. You can also work online because it is highly demanded nowadays.
-
C#: An Object-oriented Language
The second reason to study C# is that it is an object-intended programming language. Now, you might be thinking: what "object-intended" feature has to do anything with why you should learn C#? Well, object-intended indicates that it organizes data using objects and categories. This programming approach helps to minimize repeated coding and better regulates the data format. And all these factors help beginners to work efficiently and comfortably.
-
Developed By Microsoft
As discussed earlier, Microsoft created the C# programming language. It is a great reason why you should study C#. It means that there will be a plethora of excellent developer resources available to assist you in learning C# and no scarcity of its resources. And since Microsoft utilizes C# extensively, there is almost no chance that it will become obsolete in the coming years. So, mastering C# is, therefore, a long-term benefit.
So, you see, these are solid reasons as to why you must learn C#. Now, we understand that you want to learn even more about C#, and we got you there. The upcoming section is a more in-depth detail of C# so, start taking notes!
Features of C#
Now, let us discuss the main features of the C# programming language in this section which are:
-
Basic Features
- In the C# programming language, pointers are not available.
- It takes the characteristics of automated memory handling and garbage pickup from the .NET framework.
- The "::" and "->" operators are not used in C#.
- Direct memory modification and other risky activities are not permitted.
- "==" is utilized for the comparative procedure, and "=" is for task execution.
- Various ranges of fundamental kinds like Integers, Floats, and so on are available.
-
Modern Features
- C# follows the modern approach and is incredibly strong and convenient for creating interoperability and secure systems.
- Any element conversion into an online service that is accessible via the internet is provided in C#.
-
Type-Safe Features
- Dangerous conversions are not possible in the C# programming language.
- It is possible to check for an overflow of classes, and bound checking can be done.
- The translator immediately initializes numeric forms (objects and instances) to zeros or reference kinds to blank.
-
Object-oriented Features
- Data abstraction, inheritance, flexibility, and interfaces are all supported in C#.
- In Java language, basic kinds (float, int, double) are not things. However, C# has established structures that allow basic kinds to convert into objects.
-
Upgradeable and Scalable Features
- .NET has launched compositions that are self-defining in the areas of declaration. The manifest defines the assembly's identification, iteration, style, and electronic signature, among other characteristics.
- Upgrading software elements is a time-consuming and error-prone process. But, C# supports versioning within the language, which might affect the current programming languages. Sophisticated frameworks can also be established and changed over time.
- We erase old data and replace them with fresh ones to expand our system. Thanks to C#, there is no need to enroll in a flexible linking library.
-
Interoperability Features
- C# comes with built-in functionality for COM as well as Windows programs.
- C# lets clients modify outdated codes by using pointers as harmful code blocks.
- It enables local pointers to be used in a limited sense.
- With C#, Customers no longer need to construct the unidentified or other COM interfaces because these characteristics are already included.
- C# uses elements from Visual Basic for Applications (VB.NET) and other organized code technologies.
C# and C: What is the difference?
When studying the C# programming language, it is crucial to know the difference between C and C#. Both are coding languages, and that is why people often mess up between these two. But, do not worry. We will not let our readers go through the same mistake. Here is the difference: C is an overall-purpose coding language that includes features like recurrence, organized programming, semantic variable access, and many others. It is suitable for use in both system and integrated device programs. C is a limited modeling language whereas, C# is an object-intended programming language that includes features: garbage management, extensibility, type security, and uncomplicated class declarations. It may be used to create smartphones, desktops, and web applications. C# is a high-level programming language with a lot of complexity.
So, both programming languages have the same initials but, they are complete opposites of each other.
How C# Programing language works
There is a dedicated set of libraries that are required to run C# in a machine. This collection of libraries is called the .NET framework and it has a collection of libraries that are called CLR’s (common language runtime). The .NET library belongs to Microsoft who has written the library on top of common language infrastructure that is commonly known as CLI which is an internationally acclaimed standard because of the way it assists seamless development and easy usage.
When we write code in C#, it takes the form of IL (intermediate language) that is workable according to CLI specifications. These files then take the .dll extension after they are built. An assembly contains multiple dll files.
Basic Commands of C#
The basic commands of C# are quite similar to most popular languages such as C, C++ and Java. Moreover, C# is an object-oriented language so it has similar structures to the languages mentioned above. Some of the basic commands are listed below.
1. Using
The word
“Using” is used to include libraries and API’s into your C# code. It is similar to the famous
#include statement used in other languages. Any libraries written after the keyword Using will then be downloaded/included at runtime. It is also possible to have multiple Using statements in C#.
2. Class
The keyword class is used to define classes in C#. The syntax is as follows:
Class User{
….
}
3. Comments
Comments are a common feature of any programming language. Developers usually add commented code in their files for the understanding of other people or as a reminder to themselves if they ever revisit their own code and want to understand how things work.
Commented code is not compiled on run time. The compiler simply ignores any code written after/on a single line or any code written between a
/* and a
*/.
4. Member or Class Variable
Instances are a common occurrence in programming languages. In C# the equivalent term is member or class variable. These are variables that are usually declared and defined when the classes are declared and defined.
5. Identifier
Identifiers are used to declare classes, variables, methods and members in C#. it helps keep track of specific classes and variables that have been defined by the user. Identifiers have simple rules that are to be followed. The rules for C# are similar to the rules for other languages. Also, it is important to note that Identifier can never be a variable name in C#.
Components of C#
Component classes are traditional classes that were used in C and C++ and also made their way to modern C#. These classes are used mainly for the purpose of containment as well as cleanup. Components are present inside a container and can do various operations on the container they belong to. A lot of the business processing is done in these components.
Disadvantages of C#
We have discussed many advantages of the C# programming language in the above sections. Now it is time that you learn about some of the disadvantages of the C#. Please keep in mind that the advantages of C# outweighs its disadvantages. Some of the disadvantages are listed below:
- C# is a substandard x-platform GUI.
- Because C# is a component of the.NET platform, the program must be executed only on a Windows operating system.
- Because it is heavily reliant on the .Net platform, C# is much less versatile.
- C# provides less versatility than C++.
- Error correction demands a high level of expertise and understanding.
Conclusion
We hope that this article helped you in having a better understanding of the C# programming language. C# is an all-in-one programming language, and it has a bright future ahead of it. So, you should definitely give it a go because it is a long-term advantage. We wish you the best of luck on your journey! In the next tutorial, we will design our
First Project in C#. Till then take care and have fun !!! :)
How to use Comments in C++
Hello friends, hope you all are fine and enjoying your lives. Today, I am going to show you How to use comments in C++. In the previous tutorials, we first have a look at Introduction to C++ in which we have discussed a simple c++ program. After that we have discussed How to use Escape Sequence in C++, which is also essential because escape sequence is a very simple concept but is used quite a lot on C++ projects os you must have its knowledge.
Today, we are gonna discuss Comments in C++ i.e. how to use Comments in C++ and why to use Comments in C++. Just like escape sequence, comments in C++ is also very basic concept but its really important and a programmer must know How to use Comments because without it the code becomes really difficult and is quite difficult to debug. So, let's get started with How to use Comments in C++.
How to use comments in C++ ??
- Let me first explain what are comments in c++.
- Suppose you are working on some project in C++ and you complete your project and simply forget about it. Then after 2 years, somehow you got the same project and you have to use the same code then you open your code and your face must look like this. :O
- Because the code is too lengthy and you are not understanding your own code. :)
- Here comes the benefit of comments.
- Comments are not part of your code, Instead they are just used to add additional writing about the code from which you can remember what this code is actually doing.
- Let me add some comments in the Hello World program which we have designed in the Introduction to C++ tutorial.
#include <iostream> // Including Library
using namespace std; // Including Namespace Standard
int main(void) // Starting the Main Loop
{
cout<<"Hello World!!!"<<endl; //Printing Hello World in output
return 0; // Returning 0 value
}
- Now in the above code you can see I have used additional lines in front of each command.
- These additional lines are called comments and as the name suggests these are the comments about the code.
- So, now by simply looking at the code you can understand what each line is doing.
- Now you must have noticed that before starting each comment, I have used // two forward slashes.
- So, in C++ whenever you add two forward slashes, the compiler simply ignores everything written in front of these slashes, and these are called comments.
- Its one way to add a comment in C++.
- Now, sometimes there's a case when you need to add like four to five comment lines in your code then in order to add // this sign before each line you can simply enclose all the comments in between /* Here's your comment */.
- Let's have a look at this comment system below:
/*
Hello World Code
Designed by: www.TheEngineeringProjects.com
This code will print Hello Wold on output.
Date: 5/19/2016
*/
#include <iostream> // Including Library
using namespace std; // Including Namespace Standard
int main(void) // Starting the Main Loop
{
cout<<"Hello World!!!"<<endl; //Printing Hello World in output
return 0; // Returning 0 value
}
- So, in this way you can add the comments in /* */ these signs.
- You can see in above code that in the start I have given a small explanation of the project and have mentioned who designed it and when designed it.
- So, you can add such description in the comments in C++.
- Another benefit of code comes in debugging of your project.
- You think that soe of your code is not working properly then you can simply comment that code and test the remaining.
So, these are different uses and benefits of comments in C++. I hope you guys get some knowedge out of it. So, that's all for today, will meet you guys in the coming tutorial.
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:
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 !!! :)