How I learned to work with microcontrollers - a beginner's experience

Hello. In this article I wanted to talk about how I learned to work with microcontrollers
(hereinafter referred to as MK) and what pitfalls I flew into. I must say right away - the article does not claim to be exclusive, since any person working with MK went through what I went through. I ask you not to judge strictly, but to read it as a story.

Instead of joining

My first interest in MK arose when I was in 10th grade. At that time was 2009. I knew how to program a little on PC in QBasic and Visual Basic - a school program, but it happened so that I didn’t know much about programming, and the lack of knowledgeable people in electronics and MK did their job - for me it was a new niche. Although from childhood I was tinkering with boards and microcircuits found in garbage cans, but I really did not understand how it worked - nobody really could explain. How did the transistor work normally, I found out only a couple of years after the events described. When I chose the first MK, I looked at the characteristics on the CHIP-DIP website. Frankly - for me it was like hieroglyphs. So do not be afraid of it. And yes, no one had a clue about Arduino then.

How it all started

Began picking at Yandex and Google. I understood that the controller itself is half the battle, I also need a program. And as said in the introduction, I didn’t have much with programming. In the end, I got to some site. As it became clear later, I really "got" with this site. The creator of the site also wrote a programming textbook, I joyfully downloaded the textbook and the first thing I saw there was “I used PIC16F84A as a model for work”. Actually, this is how I chose my first MK. Now the question is why I "got" it. And I got there because the creator of this textbook and website suggested programming MK in ASSEMBLER. Not all practicing programmers know it, but here is a newbie ... I already ordered the controller, and only then I started reading the textbook, unfortunately.

How did I get out of position

After I realized that I didn’t understand anything, I abandoned MK for a couple of years, but at the same time I was rummaging around in forums like and others, and gradually an understanding of the issue came to me. I decided to study by the way on the model PIC16F877A.

So, what a beginner needs to know:

A microcontroller is a small computer, it also has an arithmetic-logic device - a processor in fact, and RAM and a kind of hard disk - program and data memory, but it is all done in one chip. Accordingly, depending on the model and manufacturer, it has the following characteristics (tentatively):

  • Operating frequencies from units to ~ 100 MHz, I personally use in my devices, as a rule, frequencies of 20 MHz, namely MEGAhertz, and not GIGAhertz. The frequency is set by an external clock source - a quartz or ceramic resonator.

  • RAM - units and tens of kilobytes
  • The amount of memory for data and the program is up to several tens of kilobytes. If desired, you can expand the memory for data using memory chips. In order to use these microcircuits to expand the memory for a program, a beginner should forget, not every professional can do it right, and not every microcontroller allows you to change your firmware during operation.
  • Operating voltage from 1 to 5 volts, depending on the model and manufacturer.

The microcontroller is designed to work on the board, let's say, in a specific piece of hardware, on the board, in the device. So do not think that you can play CS in it :)

Programming languages

He began to choose a programming language and an environment in which you can program. Since I somehow knew Basic, I thought that it would be nice to skip it. Yes, it is not very perfect and still a lot of shortcomings, but for a start it was very suitable. I was lucky, it turned out that there is a PIC-Basic language. According to him there is a textbook, the author Chuck Helibike and translated into Russian leadership, actually went all the way further through the textbook and manual. The environment works from under DOS, but you can screw CodeStudio and everything will work from under Windows.


The next problem that stood in my way was how to write the program to the chip. It’s clear that you need a programmer, I decided to save, I tried to collect several circuits from these of your Internet. One scheme is not enough, we also need a program that, using the programmer (the piece of hardware), will store the code in memory. All my experiments ended in failure, due to little experience. I decided not to look at the smoke coming from the chips anymore and ordered PICKit3, after that I didn’t know any problems, I played with it for a couple of days and it worked.

What a beginner needs to know:

  • Currently, there are adapted programming languages ​​for MK, the same Basic, SI and others.
  • After writing the program, it is compiled into machine code - a file with the HEX extension, it must be flashed into the MK memory.
  • In order to “flash MK” - to write executable code into it, you need two things:

    1) the programmer board, which is an intermediate device between the computer connector and the chip itself
    2) A programmer program that will know how to work with a programmer assembled according to a specific scheme.
    That is, it is necessary that the program on the PC knows which circuit is connected to the PC in order to correctly flash the chip. In my case, this is a factory solution - along with the PicKit programmer comes a disk with the necessary programs.
  • There is a limited amount of memory in MK, this must be taken into account, sometimes you have to cut out each byte of the firmware, just to get into the chip's memory. It should also be understood that there is no operating system in MK, and your firmware is the only data MK knows.

A few words about the periphery

For communication with the outside world and the convenience of work and development, various peripheral circuits are built into the MC, for example, an ADC - an analog-to-digital converter, so that you can measure the voltage supplied to the MK output without unnecessary strapping, but it should not be higher than the supply voltage, otherwise the chip will burn. Using a voltage divider, you can make a voltmeter, for example. Peripherals, the number of built-in functions and their characteristics also depend on the model, as a rule, the more expensive the model, the richer the package bundle. Also, do not forget that the controller has a limited number of legs to which you can connect.

For example, PIC16F877A has 40 of them, and 7 pieces fly out immediately, because used to power, connect the resonator and control emergency reset. You also need to carefully look at the documentation for the chip. For example, the same ADC - in the PIC16F877A, it can only measure voltage on 8 specific legs of the chip, on others it cannot. That is, for each built-in function, specific conclusions are assigned and they cannot be changed.

The essence of this fable is this

To master MK really even from scratch, but there are places where it is not very clear. If you have never encountered programming, then first learn at least the basics of programming and write “Hello World” on your computer. After that it will be easier. If you do not want to bother too much - Arduino is your everything. MK are designed for use in hardware - control units, boards, controllers, etc. etc., this is not a full-fledged computer, but a controller. And expect from him, respectively. The benefit is now full of examples on YouTube, and I hope that my experience of starting from scratch will not be so bitter and my article will help someone.


All Articles