How to Use a Simple Microcontroller Series Intro (PIC10F200) - Part 1New

Published

The idea for these tutorials came from my geek idea of trying to make some cool things using the most simple and primitive microcontroller possible. I’m not alone in this field; you can find some interesting projects here for instance: The 1kB Challenge.

Some of them are really impressive, and the first thing that comes to your mind is “How?!? How can people fit this into just 1 kB of code?”

MCU Controlled Buzzer

So I accepted the challenge and decided to try to do something like this myself and what I found was amazing. Controlling LEDs and buzzers? – Can’t be easier! Make a thermometer? – Yep! Radio-controlled robot? Obstacle avoiding robot? Robot following the line? – Why not?

Obstacle Avoiding Robot

If you are already intrigued, then this series is for you. I made this for those who want to know more deeply how things work. For those who want to understand what is hidden under the Arduino digitalRead and digitalWrite functions, who is interested in how devices communicate with each other – those who want to know how the code is implemented at a low level.

It is also intended for those who are just taking the first steps with microcontrollers and have minimal experience and knowledge. Some basic knowledge in electronic, number systems, and Boolean algebra is mandatory, but I will do what I can to accommodate those who are not familiar with these topics and you should be able to pick it up along the way.

PIC10F200 Microcontroller Overview

For the simple microcontroller, I decided on the PIC10F200 microcontroller. This is the most primitive microcontroller that is still in production and can be easily bought. This microcontroller comes in several packages – extremely tiny pinless DFN8 (2x3 mm), reasonably tiny SOT23 package (3x2.5mm) with wired pins, and the convenient-for-prototyping DIP8 (see fig. 1).

Packages of the PIC10F200 microcontrollers
Figure 1 – Packages of the PIC10F200 microcontrollers

So you can use any of these packages depending on your soldering skills and whatever device dimensions your project demands. If you don’t have any project idea in particular and just want to follow along with this series, we recommend the DIP package as it’s the easiest to work with.

The price of the PIC10F200 MCU varies from about $0.25 (in the SOT23 package) to about $0.6 (in DIP package). You can buy it from the Microchip site direct, or from some official distributor like OnlineComponents, Digikey, Mouser etc., or from online shops like eBay, Aliexpress, etc. You’re taking a risk going from an unauthorized distributor like Aliexpress but if you’re just doing it as a hobby or to learn, it won’t be the end of the world if it doesn’t work right – just frustrating. However, if you plan on selling your product or just want greater peace of mind, please, please, use an authorized source. It will make everyone’s life better.

PIC10F200 Features
PIC10F200 Features

The PIC10F200 microcontroller only has 256 words of flash memory which allows writing just 256 commands into it. In comparison, the ATMega328P, which is installed in the Arduino Uno microcontroller, has 32 kbytes of flash memory which allows you to write up to 32768 commands into it. This is 128 times more memory! But, what if I say that you can control at least half of the Arduino shields using this tiny PIC10F200? Unbelievable? It’s true though, and I’ll show you!

Assembly Programming Language

I want to warn you from the very beginning that in order to write compact code, we will use Assembly language. Don’t let this frighten you away, I promise it will not be that difficult. The PIC10F200 microcontroller we will be using has just 33 Assembly instructions, and you will normally need less than 20 of them. Easy! So, programming experience would be nice but won’t be necessary to follow along.

PIC10F200 Assembly Code

So, why assembly? What is the benefit of using it? Assembly language is a low-level language, so you write the code as close to the microcontrollers native code, the machine code, as possible. This gives benefits in both code size and execution speed. For instance, the simple LED blink program for the Arduino spends 930 bytes of the code memory (you can check it by yourself by loading and compiling the Blink example). In comparison, the same program for the PIC10F200 written on Assembly language uses just 15 words of the code memory which is 62 times more compact! If you haven’t realized, Arduino usually produces very unoptimized and excessive code. This is the price for its simplicity of use. The other price is slowing down the code execution because the microcontroller needs to execute a lot of unnecessary commands and waste time for them. Other microcontrollers and programming languages can be significantly more efficient than an Arduino but Assembly is almost always the most efficient code to run.

Don’t think that this means you should get rid of your Arduinos and start to write all code only using Assembly! I love Arduinos; they are very convenient when you need to make some prototype very fast. Just assemble the schematic using the breadboard, load the ready library into your Arduino and run it. No need to think at all – just plug and play.

The point of this series is not only to show how things are done on a lower level but also that an Arduino, in some cases, is extremely excessive and can be replaced with a $.25 microcontroller. And I want to show you how.

With the introduction out of the way, in the next articles I’ll give you all the information you need to work with the PIC10F200 microcontroller, so all the required hardware and its usage – everything except the microcontroller itself. After that, I will give you code examples with a detailed explanation of how they work. I hope these articles will build the foundation of knowledge needed for you to develop your own devices using the PIC10F200 as well as excite you and motivate you to do so. If you make something, shoot us a message with a picture of what you’ve done so we can share it on our social media outlets!

Make Bread with our CircuitBread Toaster!

Get the latest tools and tutorials, fresh from the toaster.

What are you looking for?