Home > Articles

Getting Started with the BeagleBone Black

📄 Contents

  1. Setting Up and Saying "Hello, World!"
  2. Connecting to Ethernet
  • Print
  • + Share This
In this chapter from The BeagleBone Black Primer, Brian McLaughlin walks you through where to get equipment, how to set up "Hello World," and connecting to Ethernet.
This chapter is from the book

This chapter is from the book

To get started with the BeagleBone Black, you will want to obtain the board itself and some of the basic parts. The board is available from a number of resources. The beagleboard.org website provides some great places to buy the board (see http://beagleboard.org/black). Of course, I have my favorite suppliers, which are both a major part of the Maker community:

  • SparkFun Electronics (http://sparkfun.com)—Boulder, Colorado–based SparkFun Electronics was founded on the idea of open source and open hardware. The company has an extensive catalog of electronics parts and components and consistently supports the community. SparkFun also has excellent tutorials and active forums where you can always find help on your projects. If you live in the Boulder area, be sure to watch for the in-person classes and other events the company sponsors!
  • Adafruit (http://adafruit.com)—Based in New York City, Adafruit was founded by Limor “Ladyada” Fried, a true celebrity in the Maker community. The company is another great source for all the components and parts you might need for your projects and for taking the steps to move your projects beyond the introductory ones in this book. Adafruit also has an extensive tutorial section on its website.

When I am shopping for parts, I am often torn between these two suppliers. They are both excellent companies that have provided great support to me and countless others. Determining which to use, however, shouldn’t be as much of a struggle as I might make it seem. The two companies work well together, participate in events together, and are both friendly. They represent the best of the community because they aren’t there to compete against each other; they support the community and make sure we have what we need to get our projects off the ground. If you have questions on electronics basics or more complicated techniques, you can generally find a tutorial on one of the two sites or find willing support in the forums and via email.

In each chapter, I will outline the parts you will need for that chapter’s project. We will take a practice run with this chapter and look at getting your BeagleBone Black set up and running. First, note some of the parts you’ll need:

  • BeagleBone Black
  • USB cable (USB A to USB Mini B)
  • +5 volt DC power supply (at least 1,000 milliamps)
  • Ethernet cable

The USB cable should come with the BeagleBone Black; if it does not, make sure you inform your supplier. If a friend gave you the board, then just ask nicely. To get started, you also need a way to communicate with the board. In this chapter I’m going to discuss how to connect the BeagleBone Black to another computer and also how to connect remotely via Ethernet. Another option is to connect a monitor, keyboard, and mouse directly.

Setting Up and Saying “Hello, World!”

The big moment has arrived, and it is time to power up your BeagleBone Black and start working! We start with a direct computer connection via USB. This is a simple step. Simply plug the USB cable into the BeagleBone Black and the other end into a USB port on the computer.

As soon as the board is connected to your computer, you should see the lights on the board come to life. Four lights should start blinking on the board. These are four “user” lights, labeled USR0, USR1, USR2, and USR3, as shown in Figure 3.1. There is also a power light labeled PWR. The power light should stay constantly lit. The user lights will blink with different activities. At the default boot on a clean board, you will find the user lights configured as follows:

  • USR0—This light blinks in a heartbeat pattern: two quick flashes, a pause, and then repeat.
  • USR1—This light is configured to blink on activity from the microSD card. Because the board isn’t plugged in a microSD card yet, you shouldn’t see any activity on this light yet.
  • USR2—This light flashes on CPU activity.
  • USR3—This light flashes when the built-in flash memory is accessed. The default operating system should be installed in this embedded Multi-Media Card, or eMMC, memory, so you should see activity as the board is accessing the built-in, default operating system and file system.

FIGURE 3.1 The BeagleBone Black user lights, power light, and USB port highlighted.

Next, you’re going to have to install the drivers necessary for your computer to talk to the BeagleBone Black. On a Windows 7 laptop, you just plug the board in via USB to allow a drive to mount from the board that contains driver files. Use these files directly so that you don’t have to look for them. You also have the option of downloading the drivers from the BeagleBoard organization website (http://beagleboard.org/getting-started). Drivers are available for Windows 32- and 64-bit environments, OS X, and Linux. You should refer to the specific setup instructions for your machine.

Now that you have your BeagleBone Black up and operating and have the drivers installed, what can you do? Your BeagleBone Black is already running a web server! You can use the Chrome or Firefox web browser to navigate to the board’s web server at

Navigate to the BeagleBone Black website at Your browser should present a very colorful and active website, and you should see something like the banner shown in Figure 3.2.


FIGURE 3.2 Banner from the BeagleBone built-in website letting you know everything is working just fine.

This banner gives you information about your BeagleBone Black. First, the banner is green and has a check mark. That must mean everything is good, right? Also, the banner tells you that the board is connected. These are all good indications that all is right with your BeagleBone Black’s world. Table 3.1 explains the other information that is supplied.

TABLE 3.1 Default Website Banner Information

Listed Information


BeagleBone Black

You bought a BeagleBone Black, right? This is a good sign that you bought what you thought you were buying.

Rev 000C

This tells you that, in this case, version 000 of the revision C BeagleBone Black hardware is running.

S/N 2314BBBK0577

This is the serial number of the specific BeagleBone Black.

Running BoneScript 0.2.4

The board runs BoneScript version 0.2.4. BoneScript is a version of JavaScript for the BeagleBone environments.


This is the IP address of the board on the virtualized network over the USB connection. It should match the address you typed into the address bar of the browser.

Congratulations! You’ve now successfully powered up, connected to, and communicated with your board! That was easy, wasn’t it? Let’s make a couple changes and use one of the user lights we discussed before to make it flash. About halfway down the page is a section titled “Cloud9 IDE” (IDE stands for integrated development environment). Click the header, and the Cloud9 IDE will launch in a new browser window or tab (see Figure 3.3). This is a powerful IDE running directly on the BeagleBone Black through a web interface.


FIGURE 3.3 The Cloud9 IDE running on the BeagleBone Black.

So, what is an IDE? In short, an IDE is used as an all-in-one place where you can write software directly on the BeagleBone Black. It includes an editor, a way to execute code, and many other useful features.

When a person is just starting out with a new programming language, there is a tradition that the first program they write simply displays “Hello, World!” in some manner that fits into the environment. In many languages, this is accomplished by simply printing the message, whereas in some Windows environments, an alert message is displayed. That tradition has been extended into the hardware world with a program that makes a light blink once a second.

In our case, we are approaching a board for the first time and trying out a language for the first time, so why don’t we try both displaying a message and blinking a light? Follow these steps to create a new file, write the code to accomplish our task, execute the code, and get blinking:

  1. In the main window of the Cloud9 environment you’ll find a + button. Click this button and select New File. This will open a blank text file where you can enter code. If there are other tabs open, you can close them. Feel free to peruse any “getting started” information on those pages.
  2. Enter the code shown in Listing 3.1 into the document.
  3. Save the file on the board. In this case, the file’s name is blink.js.
  4. In the environment, click the Run button.

LISTING 3.1 blink.js

1:  /*
2:   * blink.js - BoneScript File to blink the USR1 LED on the BeagleBone Black.
3:   *
4:   * Example script for "The BeagleBone Black Primer"
5:   *
6:   */
7:  var bbb = require('bonescript');  // Declare a bbb variable, board h/w object
8:  var state = bbb.LOW;               // Declare a variable to represent LED state
11: bbb.pinMode('USR1', bbb.OUTPUT);  // Set the USR1 LED control to output
12: setInterval(blink, 1000);          // Call blink fn the LED every 1 second
13: console.log('Hello, World!');      // Output the classic introduction
15: /*
16:  * Function - blink
17:  *
18:  * Toggle the value of the state variable between high and low when called.
19:  */
20: function blink() {
21:     if(state == bbb.LOW) {        // If the current state is LOW then...
22:         state = bbb.HIGH;         // ...change the state to HIGH
23:     } else {                       // Otherwise, the state is HIGH...
24:         state = bbb.LOW;          // ...change the state to LOW
25:     }
27:     bbb.digitalWrite('USR1', state); // Update the USR1 state
28: }

It will take a couple of seconds, but the code will start executing. You should see a light just next to the heartbeat light blinking on for a full second and then off for a second. Success!

Let’s step through the code you just blindly put into the environment and executed. Glad you trust me! The source starts with these six lines of code:

1:  /*
3:   *
4:   * Example script for "The BeagleBone Black Primer"
5:   *
6:   */

These lines look fairly readable to a human and not like source code. That’s because this code is what’s called a comment. A comment starts with /* and ends with the */ and includes everything in between. The extra asterisks at the beginning of the other lines are just to make things look good. There is another way to signify comments in BoneScript/JavaScript, and that is using //. These are used to describe what is occurring on a line of code. Everything from the // to the end of the line is a comment. Comments are not executed or even seen for execution. You will see a couple of different styles of commenting in different languages throughout the book.

Line 7 accesses a shared library of source code, called bonescript, that is provided to you as part of the environment:


This code accomplishes many tasks behind the scene that you don’t need to worry about for now. Access to the library is assigned to variable bbb. This means that we can use the variable bbb to access resources in that special library, as you will see on the following lines:


Line 8 declares another variable called state. We are going to use state to track whether we set our signal for the USR1 light to HIGH or LOW. When the state is set to HIGH, the voltage on the electronics attached to that light is set to +5V, and it is set to 0V for LOW. When the voltage is set HIGH at +5V, the electrical potential on the light is increased, which means the light can do work. What happens when a light can do work? It lights up!

Something important to remember here is that setting the state variable to HIGH or LOW doesn’t actually change the power supplied. We do that using a function called digitalWrite, which is a part of the bonescript library we can now access through the bbb variable. More on that function later. Now we hit a line that does something with the electricity on the board:


With this line, we are calling a function called pinMode, which is part of the bonescript library, and using another bonescript library constant called OUTPUT. This means we are configuring the USR1 pin to output the voltage rather than sensing a voltage from somewhere else in a circuit. In total, this line says, “Take the pin attached to the light USR1 and get it ready to output, please.”

The next line utilizes a function called setInterval to run the meat of the program:


This line of code tells the system to execute the function blink once every second. Line 13 has nothing to do with blinking our light. This is a simple statement that prints our classic first-time program announcement out to a console:


In the Cloud9 IDE environment, you will see this printed on a lower tab labeled “/blink.js – Running,” as shown in Figure 3.4.


FIGURE 3.4 The “Hello, World!” statement written to the console log.

The final lines define a function called blink. This function simply checks the status of the state variable and changes it to the opposite state. This function is called once every second by the setInterval function. The real meat of the function is on line 27. The call to digitalWrite makes the actual change to the hardware to change the status of the physical circuit attached to the USR1 light:


That is all the code required to use BoneScript to blink a light and print a message to the console! It is important to remember that BoneScript is defined only by the bonescript library. The underlying syntax and structure is just JavaScript, a scripting language used in many places on the Web. This means that you can use JavaScript tutorial and reference resources to help you understand or to get any clarification.

For simple examples throughout the book, I will stick to BoneScript just to make it easy. For more complex code and functionality, I use other programming languages such as C/C++ and Python. I will comment the code to help with readability if you are not familiar with those languages; however, I highly encourage you to seek out other resources to learn those languages in depth because that is not the focus of this book. The next chapter will delve into some more complex development with BoneScript and the Cloud9 IDE to enable your own explorations. It will also introduce you to the basics of programming with other languages.

  • + Share This
  • 🔖 Save To Your Account