To program micro controller, you first need to know the number system. Notice the number 1234567890, a very unique number so that we have all the (ten) digits we need. But even the most powerful computer in the world is so stupid that it does not have the ability to understand these numbers. How do you know, he doesn't have a brain like a human being anymore. He understands, there is power, there is not. If there is power 1, if not 0. So to explain the computer, the above number has to be changed to 0 and 1. Expressing the number with 0 and 1 stands for 1001001100101100000001011010010. Now to write the number 1234567890 since I have used these ten numbers 1,2,3,4,5,6,7,8,9 and 0 So this type of number system is called decimal number or decimal number whose base is 10, but next time I only used two numbers 0 and 1 so this type of number will be called binary number or binary number whose base is 2. There are also two more types of number systems called Octal and Hexadecimal. In the case of Hexadecimal, there are 16 numbers 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F. Decimal, binary and hexadecimal are the three types of numbering systems commonly used in programming. In binary system, each digit is called Bit. For example, 10011110 This binary number has a total of eight bits, the bit on the far right is called Least significant bit (LSB) and the bit on the far left is called Most significant bit (MSB). Listening to the name, you can understand that the local value of Least significant bit is less, that is, the number changes very little. For example, converting 245 to binary is 11110101. Now if you change the bit on the far right (LSB) to 0, the number becomes 11110100, if you convert it to decimal, it becomes 244. If you change the bit 1 on the left (MSB) to 0, the number is 01110101, if you do it in decimal, 117, you can understand the matter. In Binary System, the bit on the far right is 0 bit, the next 1 is bit, the next is 2 bit, so in Binary System you have to start counting from the right side and start counting from 0. You can use Windows' own calculator to switch from one number system to another.

Now come to micro controller programming. First I will start with assembly as a programming language and then I will use C. We will be working with Microfhip Company's PIC Microcontroller's 16f series 8 bit controller. There are only 35 instructions in the assembly for this series. The software that we will use for this is Pic Simulator Ide, Proteus, MikroC.

The PIC16f84A is an 8-bit microcontroller, with all 16f series microcontrollers with flash memory, so it can be programmed as many times as you like, like a pen drive. Many people may be tense about how to program. There is no need to tension. You can create a serial jdm programmer for just under 250 rupees. I will show in one of the tutorials how you can easily create a PIC programmer in PCB at home. The bad news for those who use laptops is that they need a microcontroller to create a USB programmer, which will require another programmer to program. In fact, the story is a lot like before the chicken, or before the egg. The good news is that Microchip has unveiled the schematic diagram and code of a very powerful USB programmer called PICKIT2 to increase the popularity of its microcontroller. This is not a problem once you learn to make PCB.

Notice the image below,







The picture shows the names and numbers of different pins of the microcontroller. I will give a detailed description of the pins. Table-1.1 of page-4 of the datasheet has written about the pins. Microchip's datasheet is very informative, read more then everything will be clear.

RA0 to RA4: RA0, RA1, RA2, RA3, RA4 These five pins together we can call PORTA. Since there are five pins under PORTA and if we think of each pin as one bit then RA0 will be 0 number bit of PORTA and RA1, RA2, RA3, RA4 will be 1,2,3,4 number bit of PORTA respectively. Writing PORTA = 11010 means RA4 = 1, RA3 = 1, RA2 = 0, RA1 = 1, RA0 = 0. RA0 = 1 means, if you measure the voltage relative to the ground in the pin number RA0, you will get 5 Volt, that is, the RA0 pin is high. In the same way RA0 = 0 means that if you measure the voltage relative to the ground in the pin number RA0, you will not get any voltage difference i.e. the RA0 pin is low. PORTA is a bi-directional port, meaning that each of its pins can be used in both input and output.

RB0 to RB7: RB0, RB1, RB2, RB3, RB4, RB5, RB6, RB7 These eight pins belong to PORTB. The properties of PORTB are similar to those of PORTA. The only difference is that the PORTA port is 5 bit and the PORTB port is 8bit. This PORT can be used either input or output. This also means Bi-directional port.

VSS and VDD: These pins are the power supply pins of the micro controller. VSS is the ground pin and VDD is the positive supply pin.

OSC1 / CLK IN and OSC2 / CLKOUT: To run any digital IC, clock pulse is required. The micro controller completes each instruction through clock pulse. To give these two pins clock pulse. PIC16F84 can work with a maximum of 20MHz clock pulse so you can put a maximum of 20MHz crystal.

MCLR: This pin is the Master RESET pin of the micro controller. If you look at the picture above, you will see that there is a bar on the name of this pin. This means that the pin is inverted, which means it will be active if you apply zero volt. This PIN is also used during micro controller programming. Normally this pin becomes a resistor and is connected to the positive supply and if you want to reset the micro controller, you just have to connect the pin to the ground. Resistor to limit current.

The RB0 pin of Int: PORTB can be configured and used as an INTERRUPT pin. This will be discussed in detail later.

TOCK1: Configure the RA4 pin of the PORTA to run the internal timer / counter of the Micro controller to give clock pulse input to this pin. This will be discussed in detail later.