Guide
1/12/2018 mbed Starter Kit Experiment Guide - learn.sparkfun.com
https://learn.sparkfun.com/tutorials/mbed-starter-kit-experiment-guide/all 19/65
Concepts
We touched on a few important concepts in this tutorial that you may want to understand.
Serial Communications
To communicate between the mbed and the LCD, we are relying on a protocol known as UART. While you can create a program that emulates UART, it is far
easier to rely on the mbed’s built-in UART hardware peripherals. We are using pin 9 and pin 10, which are the TX and RX lines, respectively, of one of the
LPC1768’s UART peripherals. To read more about UART and serial communications, see this tutorial.
Libraries
Many software programs rely on “libraries.” A library is a separate program or programs that may be called upon to perform one or several functions. We
interface with libraries by linking to them in our project (the “Import” step in the mbed Compiler) and using the “#include” command in our main program. This
tells the compiler to include the header file (“.h”), which makes functions in the library available to us (e.g. the uLCD_4DGL class and methods, such as
background_color()). Many mbed libraries can be found in the Handbook and the Cookbook.
For this guide, we are using forked tutorials so that the versions stay the same. When you start making projects on your own, we highly recommend using
libraries from the original author (or write your own!). As you start developing projects using other people’s libraries, you’ll notice that they might update their
library from time to time. If you see a little green circular arrow around the library icon in your project, that means the library has been updated. To update the
library to the latest revision, right-click on the library in your project viewer and select “Update…”
The Super Loop
Many simple embedded systems use the concept of “setup” and “loop” (more powerful embedded systems often use a Real-Time Operating System). For these
tutorials, we rely on setting up some parameters and then looping forever within a while loop. This type of structure is known as a super loop architecture.
For mbed, the super loop architecture looks like:
int main() {
// Setup code goes here
while (1) {
// Loop forever code goes here
}
}
We can declare functions outside of main, which can be called within either our setup or loop code. Additionally, we can declare variables outside of main (and
other functions), which are known as “global variables”.
This super loop template is a great starting place for many simple embedded programs.
Graphics
The realm of computer graphics is vast. We only touched on the beginning with simple text and shapes. Even if we do not go in-depth into graphics, we
recommend you familiarize yourself with some graphics terms such as framebuffer, frame rate, and refresh rate.
Going Further
Now that you have learned about libraries and graphical displays, you are well on your way to becoming an mbed expert. We will be using the LCD in the coming
tutorials, so don’t disconnect it yet!
Beyond the Tutorial
Can you make the circle bounce up and down as well as side to side?