A microcontroller is a single chip; self-contained computer which incorporates all the basic components of a personal computer on single integrated circuit (IC). These small devices can do so much great jobs that only our imagination is the limit. A basic understanding of electronics and digital circuits is all that is required to get started. Think of any logical application and you will find microcontroller handling the work well. Industrial automation including automatic assembly lines, robots and quality control systems all are backed by some kind of microcontroller.
So exactly why microcontroller or a microprocessor? This is the question which needs to be clarified before putting the heads down. Integrated circuit (IC) is small device, with lots of circuitry inside it, with few connections for external interface. We have several ICs with numerous functionalities in terms of tasks they are meant to perform. The circuit inside an integrated circuit which is composed of many components either digital or analog is designed for a purpose. For instance, LM 380 is designed as an audio amplifier and all the necessary circuitry are inside to make a complete audio amplifier IC. Similarly a 7447 is a binary to 7-segment decoder, and has input pins to accept binary coded decimal (BCD) number; the output pins will then turn on and off accordingly to display the number on a 7-segment display. We have hundreds and thousands of ICs with specific functions in the world of electronics. In order to make good use of these ICs, devices data sheet must be well understood by the circuit designer for any application.
On the other hand, microcontrollers and microprocessors are integrated circuits, but they differ fundamentally from other ICs. They are a class in themselves, that the designers have not made them to do a particular function. They are like a plain sheet of paper waiting for pen to put content on them. When they are newly purchased, they have no content in them (no specific function like LM 380 or 7447 or 555 timer). In order to get them useful, we have to put content in them thus programming comes in. Thus a microprocessor or microcontroller can be programed to read the input signal from a sensor and control a particular output (e.g. stepper motor or DC motor) based on the input signal status. While the same IC can be configured later, to read the status of an infra-red sensor, decode the signal and turn another device ON or OFF. If these two types of circuitries were to be made using conventional digital ICs, it would have required a large number of components and any change will require an entire change of the hardware design. In the case of microprocessor or microcontroller, the same IC, can be programmed to do different tasks, and any change in specifications can easily be implemented by just changing the coding. This greatly facilitated the engineers and hobbyists to rapidly develop new electronic devices, and continuously improve previous ones. Design times, time to market and hardware requirements are now decreased. Large hardware designs were reduced, and most of the circuitry was replaced by the configuration scripts (programs).
Today we call the ability to configure a microprocessor or microcontroller, programming. A program is nothing but a series of instructions, in a correct and logical manner to instruct the microprocessor or microcontroller on the desired function. Thus you have to learn the instructions your particular microcontroller understands, and what those instructions order it to do. Then it’s your mind, and ideas how you play with these instructions to get your job done. Literally there are hundreds of methods to get the same job done. A microcontroller is a complete, small scale computer with all the necessary devices on-board. All you need is the external hardware, to take in input and control output like sensors and motors.