Bit Banging

Shlomo Engelberg, an associate professor in the electronics department of the Jerusalem College of Technology, is well-versed in signal processing. As an instructor and the author of several books, including Digital Signal Processing: An Experimental Approach (Springer, 2008), he is a skilled guide to how to use the UART “protocol” to implement systems that transmit and receive data without a built-in peripheral.

Implementing serial communications using software rather than hardware is called bit-banging, the topic of his article in Circuit Cellar’s June issue.

“There is no better way to understand a protocol than to implement it yourself from scratch,” Engelberg says. “If you write code similar to what I describe in this article, you’ll have a good understanding of how signals are transmitted and received by a UART. Additionally, sometimes relatively powerful microprocessors do not have a built-in UART, and knowing how to implement one in software can save you from needing to add an external UART to your system. It can also reduce your parts count.”

In the excerpt below, he explains some UART fundamentals:

UART stands for universal asynchronous receiver/transmitter. The last three words in the acronym are easy enough to understand. “Asynchronous” means that the transmitter and the receiver run on their own clocks. There is no need to run a wire between the transmitter and the receiver to enable them to “share” a clock (as required by certain other protocols). The receiver/transmitter part of the acronym means just what it says: the protocol tells you what signals you need to send from the transmitter and what signals you should expect to acquire at the receiver.

The first term of the acronym, “universal,” is a bit more puzzling. According to Wikipedia, the term “universal” refers to the fact that the data format and the speed of transmission are variable. My feeling has always been that the term “universal” is basically hype; someone probably figured a “universal asynchronous receiver/transmitter” would sell better than a simple “asynchronous receiver/transmitter.”

Figure 1: The waveform output by a microprocessor’s UART is shown. While “at rest,” the UART’s output is in the high state. The transmission begins with a start bit in which the UART’s output is low. The start bit is followed by eight data bits. Finally, there is a stop bit in which the UART’s output is high.


Before you can use a UART to transfer information from device to device, the transmitter and receiver have to agree on a few things. First, they must agree on a transmission speed. They must agree that each transmitted bit will have a certain (fixed) duration, denoted TBIT. A 1/9,600-s duration is a typical choice, related to a commonly used crystal’s clock speed, but there are many other possibilities. Additionally, the transmitter and receiver have to agree about the number of data bits to be transmitted each time, the number of stop bits to be used, and the flow control (if any).

When I speak of the transmitter and receiver “agreeing” about these points, I mean that the people programming the transmitting and receiving systems must agree to use a certain data rate, for example. There is no “chicken and egg” problem here. You do not need to have an operational UART before you can use your UART; you only need a bit of teamwork.

Using a UART is considered the simplest way of transmitting information. Figure 1 shows the form the transmissions must always make. The line along which the signal is transmitted is initially “high.” The transmissions begin with a single start bit during which the line is pulled low (as all UART transmissions must). They have eight data bits (neither more nor less) and a single stop bit (and not one and a half or two stop bits) during which the line is once again held high. (Flow control is not used throughout this article.)

Why must this protocol include start and stop bits? The transmitter and the receiver do not share a common clock, so how does the receiver know when a transmission has begun? It knows by realizing that the wire connecting them is held high while a transmission is not taking place, “watching” the wire connecting them, and waiting for the voltage level to transition from high to low, which it does by watching and waiting for a start bit. When the wire leaves its “rest state” and goes low, the receiver knows that a transmission has begun. The stop bit guarantees that the line returns to its “high” level at the end of each transmission.

Transmissions have a start and a stop bit, so the UART knows how to read the two words even if one transmits that data word 11111111 and follows it with 11111111. Because of the start and stop bits, when the UART is “looking at” a line on which a transmission is beginning, it sees an initial low level (the start bit), the high level repeated eight times, a ninth high level (the stop bit), and then the pattern repeats. The start bit’s presence enables the UART to determine what’s happening. If the data word being transmitted were 00000000 followed by 00000000, then the stop bit would save the day.

The type of UART connection I describe in this article only requires three wires. One wire is for transmission, one is for reception, and one connects the two systems’ grounds.

The receiver and transmitter both know that each bit in the transmission takes TBIT seconds. After seeing a voltage drop on the line, the receiver waits for TBIT/2 s and re-examines the line. If it is still low, the receiver assumes it is in the middle of the start bit. It waits TBIT seconds and resamples the line. The value it sees is then used to determine data bit 0’s value. The receiver then samples every TBIT seconds until it has sampled all the data bits and the stop bit.

Engelberg’s full article, which you can find in Circuit Cellar’s June issue, goes on to explain UART connections and how he implemented a simple transmitter and receiver. For the projects outlined in his article, he used the evaluation kit for Analog Devices’s ADuC841.

“The transmitter and the receiver are both fairly simple to write. I enjoyed writing them,” Engelberg says in wrapping up his article. “If you like playing with microprocessors and understanding the protocols with which they work, you will probably enjoy writing a transmitter and receiver too. If you do not have time to write the code yourself but you’d like to examine it, feel free to e-mail me at I’ll be happy to e-mail the code to you.”

Newcastle Makerspace’s first rule? Do not be on fire.

1069828_219774724881137_1206270128_nIn Newcastle upon Tyne, located in North-East England, lies Newcastle Makerspace. This is an eclectic group of makers, creatives, programmers, scientists, and engineers. They’ve set up a space to meet, work, socialize, share ideas and collaborate.

Gregory Fenton is a member and wants to tell us a little bit more about what they’re working on.

Location 18 New Bridge Street West, Newcastle upon Tyne, NE1 8AW, England
Members Lots and growing fast.

CW: Tell us about your meeting space.

We have 2 large rooms, one for relaxing, holding meetings and talks etc., and one for working on projects. We also have a fully networked computer room with spare monitors and keyboards for people who bring in their Raspberry Pi. Another room is dedicated to our lathe and laser cutter. There’s a kitchen area so people can prepare meals and make drinks and a well-organized storage rack.

CW: What sort of tools do you have at Makerspace Newcastle? 

  • Oscilloscopes
  • Soldering stations (including SMD soldering using heat)
  • Two 3D printers (both working and being built by members)
  • A lathe
  • A laser cutter (ordered, just waiting on delivery)
  • Computers
  • Bench drills and saws
  • Circular saws, sanders, grinders, and lots of general hand and power tools

CW: What’s on your wish list? 

A laser CNC and newer tables and chairs would be nice additions.

CW: What sort of embedded tech does your group work with? 

We use lots of embedded technology such as Arduinos, BeagleBoards, Raspberry Pis, PICs, etc… for various projects.

CW:  What are some projects that your group has been working on?

We have so much going on, projects that come to fruition and projects just being imagined that I could go on for ever!

  • One of our members is building a large quadcopter from scratch with a 3D camera mounted underneath it.
  • Another is working on a candy machine that feeds the Makers whenever someone tweets to it (give it a try by sending a tweet containing the word candy to @maker_space).
  • Several of our members are building 3D printers of various styles and sizes.
  • One of our members designs costumes for shows, circuses and events.
  • A different member is taking his children’s old baby clothes and making a quilted “memory blanket,” as well as creating wooden toys to give to them now they are a little older.
  • Some of our junior members are learning about programming, interfacing to electronics and relays, and making toys by hand from balsa wood.
  • One of our members is creating a power extension that is controlled remotely using Arduinos, servo motors and a GSM shield to switch on and off individual plugs via text message (SMS).
  • A project that’s being done as a group is a Raspberry Pi media server that plays music and controls other devices such as an amplifier, lights and LED strips. I don’t think this project will ever truly be finished as every completed task leads to “wouldn’t it be cool if we did …”.



What’s the craziest project your group or group members have completed?

Easy. We decided we wanted a laser cutter, went on a members pledge drive and had the money to buy it outright within a week! It is in China at the moment but soon we’ll be cutting out plexiglass and wood like there is no tomorrow!


We regularly hold events both in the space itself and in other places in the surrounding area. Check our blog and mailing list from our website for upcoming and past events.

What would you like to say to fellow hackers out there?

  • Always follow rule zero: Do not be on fire.
  • Safety is everyone’s responsibility.
  • Don’t have a space local to you? find a few like minded individuals and set up your own! You can start small (a garage or shed) and expand as time passes and membership increases.
  • If a project interests you, tell the world. Circuit Cellar, Blog, Facebook, Twitter… Spread the word.

Want to know more about what Makerspace Newcastle does? Check out their Facebook and Twitter page!


A Quiet Place for Soldering and Software Design



















Embedded Programming: Rummage Around In This Toolbox











Jens Altenburg’s project


An Organized Space for Programming, Writing, and Soldering









