I'm just starting off in electronics and am already fascinated. Having played with an Arduino these past few days I'm aware that binary is a representation of different voltages - such as +5V representing 1 and GND representing 0.

I've been trying to discover how, at a physical level, the microcontroller converts the binary to these voltages. I cant seem to find a description anywhere. Can anyone share their knowledge or point me to a place/good book that describes how this works?

  • 1
    \$\begingroup\$ I don't remember which one it was, but have a look at this video. Good content. \$\endgroup\$ – abdullah kahraman Jan 14 '12 at 18:50
  • 2
    \$\begingroup\$ Actually, micro-controller doesn't convert the binary to the varying voltages. Binary is the voltage. A +5V is denoted as a "HIGH" or "1". And 0V is denoted as a "LOW" or "0". Go and have a look at electronic switches, or more in detail; MOSFET. \$\endgroup\$ – abdullah kahraman Jan 14 '12 at 19:02
  • \$\begingroup\$ You are NOT asking about "analog to digital" or "digital to analog" conversion, right? \$\endgroup\$ – abdullah kahraman Jan 14 '12 at 19:21
  • 3
    \$\begingroup\$ It might help to think of it the other way around. 'Binary' is a sort of symbolical mathematical entity that we humans like to reason with. Logic circuits can represent binary with differing voltages. We design logic circuits so that what the circuits do with the voltage levels will make consistent logical sense when we humans interpret those voltages as binary numbers. \$\endgroup\$ – JustJeff Jan 14 '12 at 20:47
  • 1
    \$\begingroup\$ @abdullahkahraman You're correct, I don't think I am talking about DAC, as you say. Thanks for the link to video, it's very informative. And by way of that, you've also introduced me to the MIT OCW site, which looks like it'll be a great resource for learning. Thanks! \$\endgroup\$ – Matt Jan 14 '12 at 22:30

I want to restate part of KellenJB's answer in a slightly different way:

There is no conversion from binary 1's and 0's to voltages like 5 V and 0 V. The microcontroller, or any physical circuit, just operates on the voltages.

Those voltages are "converted" to binary 1's and 0's in our heads when we form a simplified model in our minds about how the circuit is working.

  • 2
    \$\begingroup\$ Yes. Yes, yes, yes, and (oh yeah), yes. \$\endgroup\$ – JustJeff Jan 14 '12 at 20:48
  • 1
    \$\begingroup\$ And I would add that to be a 0 the voltage just needs to be close to 0 or below a threshold (say < 0.8v) and to be a 1 greater than a threshold (say > 2.0v). The thresholds differ by the technology used to build the device and the operating supply voltage 5v in his case. \$\endgroup\$ – kenny Jan 14 '12 at 21:39
  • 1
    \$\begingroup\$ Thanks all. So once a computer is running, there is no actual passing around of binary machine code at all? The binary code, when uploaded as firmware is presumably then stored in memory which when 'accessed' by the processor responds with a a cycle of voltages which correspond to the binary? (Hope this makes sense) \$\endgroup\$ – Matt Jan 14 '12 at 22:39
  • \$\begingroup\$ To be "uploaded", the code must already be in some physical form: voltages on a wire, the positions of some levers (or keys on a keyboard), whatever. In memory, the bits are stored as accumulations of charge on a capacitor...which also generates a voltage on the capacitor. \$\endgroup\$ – The Photon Jan 15 '12 at 0:40
  • 1
    \$\begingroup\$ My point of view is, shapes on a screen or printed on a piece of paper are just lights or blobs of ink, until our minds interpret them to mean one or zero. Imagine a letter printed in an alphabet you don't know (say, Cyrillic or Thai). It's just a blob of ink until a Russian or Thai person comes along to interpret it and know what sound it represents. But this philosophical distinction is probably getting us off topic. \$\endgroup\$ – The Photon Jan 18 '12 at 18:23

There isn't really a "conversion" that takes place. Binary 1s and 0s is just a virtual representation of the underlying voltages. In fact, in many systems a high voltage might mean 0 while a low voltage means 1. There are some reasons why this is done, but probably more then you care to dive into this early on.

To understand what is happening in the logic, it is probably best to look into the transistor. A transistor can be used for many things, but at a simple level you can treat it as a switch. Conceptually you can think of it just like your light switch on the wall, but instead of being controlled by physically moving the switch it is controlled by the change in current. You could treat the light being on as a 1 and the light off being a 0. Now you can start to combine these switches in varying sets to create different logic elements (like AND, OR, NOR, etc).

I know my answer isn't horribly detailed, but I hope it will answer your question. If you need more explanation I will be willing to add more detail, just don't want to overwhelm you.

  • \$\begingroup\$ Thanks all for the great replies!! Would I be right to think then, at a simplistic level, the microprocessor runs at a certain clock speed and on each cycle sends an instruction set ( voltage relating to binary values?) through these transistors, which act as logic gates. And the transistors then produce a relevant output based on the combined logic (and, or, NAND etc)? \$\endgroup\$ – Matt Jan 14 '12 at 22:22
  • 1
    \$\begingroup\$ Simplistically... yes. There are a lot of abstractions layers here. It is difficult to explain everything going on here in a single answer as it takes a lot of layers of abstraction before you can understand everything. It can easily take a few college level classes to teach it all. You can either just take things as they are on the surface or prepare for a lot of learning. \$\endgroup\$ – Kellenjb Jan 14 '12 at 22:35
  • \$\begingroup\$ Thanks @kellenjb, you've been really helpful. I'm encouraged to learn more! \$\endgroup\$ – Matt Jan 14 '12 at 22:42

The short answer is it doesn't "convert", the voltages are the binary (or a representation of it). Just like if you write a number on some paper the marks are a representation of the number, or count on an abacus the stone positions are a representation of a number.

Binary is a number system, just like decimal (or octal, hexadecimal, etc)

While decimal (base-10) has 10 symbols (0123456789) binary (base-2) only has two (01)

The sequence 10 in any base means the base to the first power, so in decimal 10 means 10^1 = 10, and in binary it means 2^1 = 2. Following on, 100 in decimal means 10^2 = 100, and in binary it means 2^2 = 4. And so on.

To represent decimal using electronics would be possible but complicated, so they chose binary which can be represented by simple 0 and 1 (or on/off)
There were variations on this, like ternary (3 states) systems and of course analogue computing. Before transistors, there were mechanical punch card machines (google knows plenty, some very interesting reading if you have the time)
The earliest binary digital computers were made with real switches (electronic relays). The Zuse Z3 (1941) is an example:

Zuse Z3

After this vacuum tubes were used instead of relays (could switch faster with no moving mechanical parts), which performed the switching instead of relays. The ENIAC is an example of an early computer made with vacuum tubes.

Then in the 60's transistors arrived and soon after ICs. The transistors perform the same function that the relays/valves had in earlier machines, but were a lot smaller, faster and consumed less power.

The actual theory behind the basic way binary computer circuits work hasn't changed at all, just like we haven't changed the way we manipulate numbers in mathematics - algorithms improve but the basic rules remain the same.

So if you know how binary works, and you have a simple circuit capable of storing either a 1 or 0 as two different voltage levels (e.g. 5V and 0v), and other simple circuits that can perform simple logical functions like AND and OR, then you can combine them all to do more complex stuff.
Since all these binary circuits are just switches at the most fundamental, you can achieve the same thing with anything that can alternate between two states like mechanical/relay/valve/transistor/?.

To give an example of storing a number in binary, lets say we have 8 switches (what type they are isn't important)
A 1 is represented by 5V and a 0 is represented by 0V.
We want to store the number 123.

In decimal it is 123 = (1 X 10^2) + (2 * 10^1) + (3 x 10^0)
In binary it is 01111011 = (0 x 2^7) + (1 x 2^6) + (1 x 2^5) + (1 x 2^4) + (1 x 2^3) + (0 x 2^2) + (1 x 2^1) + (1 x 2^0)
So all we do is set switches 0,1,3,4,5,6 to 5V and switches 7 and 2 to 0V. This "stores" the number 123 in binary. This setup would be known as a "register".

If you want to know more about how the switches are combined to form more complex circuits get yourself a good book on digital logic or ask google.

This site doesn't seem to be too bad to start with.


The program you are running is using voltages that represent ones and zeros. Everything about that digital part is voltages either close to ground or close to the supply voltage (5V in your example). When you load a processor register with 0xFF lets say you are creating 8 separate 5Volt signals somewhere in the chip. When you then store that register value in a control register that is related to the output ports, the output pins on the device the 5V signals in the processors register then cause other 5V signals to be created that are connected to the external pins of the device.


The voltages are just a way of representing the binary. It is a quite efficient and practical conversion that allows for binary logic to be implemented using different transistor configurations.

The way binary logic is usually implemented electronically is by using CMOS ( http://en.wikipedia.org/wiki/CMOS ) technology, in which two MOS transistors are set up in a complementary pair to form a CMOS gate. There are other electronic implementations of binary logic though, using TTL ( http://en.wikipedia.org/wiki/Transistor–transistor_logic ) for example, or relays. But you could use anything really, paper, paper robot goats: http://www.robives.com/category/product_tags/logic_goats . The electronical CMOS implementation just happens to be an efficient and practical one.

Out of these simple CMOS gates, you can build more complicated logic gates: NAND and NOR, the standard gate being NOT, are the basic ones. Out of these, you can build everything that is binary logic, an adder, a register file, memory. Out of these you can build an ALU, all the way up to a complete microprocessor.

If you want more information, you can read a book about digital logic, I happen to own and like this one:


A nice practical way for understanding how a CPU is built is just to build one yourself, using VHDL and a FPGA. You can get cheap FPGA development boards and the software is usually free (for a restricted license). I have a few by digilent which are quite affordable:



Simply put, in a given range (usually from 5 to 12 volts) the most significant bit is 0 in the first half of that range and 1 in the other. The next most significant bit is calculated by further dividing that half in two and so on until all the bits have been calculated.

Therefore, binary is just about increasing and decreasing voltages that are measured periodically.

Here's a simplified example. In the range from 1V to 256V, let's translate (analog) 137 to binary (numeric) using pseudocode:

// used this way: analogToNumeric(137, 256);
function convert(var number, var length) {
    if (number > length) { return(ERROR); }
    function convert(var half, var binary) {
        if (half < 2) { return(binary); }
        elseif (number < half) {
            return(convert((half / 2), append(binary, 0)));
        } else {
            return(convert((half / 2), append(binary, 1)));
    } return(convert((length / 2), list()));

protected by Dave Tweed Nov 2 '15 at 12:15

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.