Bachelor of Engineering / Science
Module Laboratory Reports
Bachelor of Engineering / Science
in Electronic Engineering
Data Structures and Algorithms
Lee Siang Wei
Academic Year 2014/15
Department of Engineering Technology
School of Engineering
Waterford Institute of Technology,
Table of contents
What is mbed 3
Scope of project 4
Details of main components 5-6
Block diagram 7
Wiring diagram 7-8
Implementation & Testing
Implementation step by step guides 12-14
Testing & Results 15-17
Problems Encountered 18
Future Recommendations 18
What is mbed?
mbed is a platform for developing smart devices that are based on 32-bit ARM
Cortex-M microcontrollers. It is designed to provide a highly productive solution for
rapid prototyping and product development, with a focus on connected Internet of
It is a project developed by ARM, its technology partners and a community of core
developers, and it is used by tens of thousands of professional developers to create
intelligent products that take advantage of the power of modern microcontrollers and
connectivity. The mbed microcontroller was the first hardware used to bootstrap the
mbed platform, used for creating smart devices based on ARM Cortex-M
The mbed software development kit (SDK) provides the mbed C/C++ software
platform and tools for creating microcontroller firmware that runs on smart devices. It
consists of the core libraries that provide the microcontroller peripheral drivers,
networking, RTOS and runtime environment, build tools and test and debug scripts. A
components database provides driver libraries for components and services that can
be connected to the microcontrollers to build a final product.
The mbed hardware development kit (HDK) provides the recipes to build custom
hardware for devices that support the mbed SDK. This consists of interface firmware
and schematics of the microcontroller subsystems that can be used to easily create
development boards, OEM modules and re-programmable/hackable products suitable
for production and that can take advantage of the mbed software platform and
development tools. There are various hardware platforms based on the HDK available,
with the first platform being the original mbed Microcontroller board used to
bootstrap the project.
The mbed platform now supports different ARM Cortex-M hardware though porting
of the mbed SDK to support new microcontrollers, and use of the mbed HDK to
create custom boards that support the software platform.
Scope of project
The scope of this project is that to capture a photo for a racing car when the sensor
detects the motion of itself before reaching the final line. The photo will then save
into a SD memory card.
Details of main components
In the construction of this project, it consists of some of the main components: mbed
LPC1768, PIR Motion Sensor, LS-Y201 Camera and Breakout Board for microSD.
The mbed Microcontroller (more precisely mbed NXP LPC17680) is based around an
NXP microcontroller, which has an ARM Cortex M3 core, running at 96 MHz, with
512 KB flash, 64 KB RAM, as well as several interfaces including Ethernet, USB
Device, CAN, SPI, IC and other I/O. It is the most important part of this project as it
control all the activities of the project.
For LinkSprite JPEG color / infrared camera, it is used to capture and output JPEG
images through UART, making it easy to integrate into an existing design. It can
capture high resolution pictures using the serial port.
PIR motion sensor with Grove compatible interface allows to sense motion, usually
human movement in its range. Simply connect it to Grove - Base shield and program
it, when anyone moves in its detecting range, the sensor will output HIGH on its SIG
pin and then activate the capture function of camera. Otherwise, it will output LOW.
It is used to detect the motion of people.
Breakout board for the microSD socket compatible with the SPI interface found on
any SD card, this tiny form factor was created for any media storage such as music
In this project, the modular design is employed. The block diagram of this project is
The PIR Motion Sensor acts as input as it detect the any tiny movement of things so
that it can send the signal to the main brain mbed LPC1768. Therefore the LPC 1768
will collect and progress the data in order to determine whether to activated the
infrared camera to take picture and then save the picture into microSD or not.
The schematic diagram for this project without SD breakout board is shown above.
There are total 5 pins of LPC 1768 used in this project, pin VOUT, pin GND, pin 13,
color / infrared
14 and 21. The VOUT is the positive side of power supply which supply the voltage
to each of the components. On the other side, the GND is ground that all the ground
of components must be connected to it. Pin 13 is TXD which is connected to the RXD
of the LS-Y201 Camera while pin 14 is RXD that connected to the TXD of the LS-
Y201 Camera. Pin 21 is the receiver signal where it connected with the pin OUT of
PIR Motion Sensor. With SD breakout board, the connection pins is shown as below:
SD Breakout Board Mbed
CS Pin 8
DI Pin 5
VDD Pin 40 (VOUT)
CLK Pin 7
VSS Pin 0 (GND)
DO Pin 6
RSV, S1 & S2 -
Each of the components gets their power supply from LPC 1768 to perform their
function as well. Therefore each of the positive side and negative side of voltage of
the components has to connect with positive and negative of LPC 1768
simultaneously. For the LS-Y201 Camera, pin TXD work as transmitting data out to
LPC 1768 and pin RXD is work as receiving data from LPC 1768. When the motion
is detected, the PIR Motion Sensor will send a high signal to pin 21, the LPC 1768
will collect the signal and process it. After processing, it will send a signal from TXD
of itself to RXD of LS-201 Camera. At this time, the camera will start to take a photo
and then the data will send back to the RXD of LPC 1768 for memory storage.
The software is designed in order to support the effectiveness of the hardware device.
The software was written in C language, and was written in sections for easy
debugging and troubleshooting. Each section is tailored to meet the duty that will be
imposed on the corresponding hardware unit.
i) Inclusion of library
First, I have to include the library of mbed.h so that the program can run smoothly
without any debugging error. This is because I use the platform of mbed to run this
project. Besides, I have to include the library of Camera_LS_Y201.h and
SDHCFileSystem.h in order to make me easier to troubleshoot the program if any
debugging error exist. Of course, you can insert all the codes into the same form too.
For PIR Motion Sensor, pin 21 defined as pin receiving signal from it, mean that
when any motion is detected, pin OUT of PIR will send signal to this pin. In addition,
pin 13 and 14 of LPC 1768 also defined simultanuesly as TXD and RXD in early
ii) Definition of SD Card
USE_SDCARD is a variable that have to defined for memory storage of captured
images. The codes above explained that 2 condition:
if SD card is detected, the captured images will automatically save into the
SD card with name of /sd/photos/IMG_%04d.jpg
if SD card is not exist, it will save into another local file with name of
iii) Main program
Firstly, the camera has to reset as 0 in order to detect the connection of pin TXD and
RXD whether they both connect to the RXD and TXD of LPC 1768 or not. If the
condition didnt meet, it will display Reset fail. on the screen and the camera wont
take any photo as there are no connection between LPC 1768 and LS-Y201 camera.
Once both the connection are detected, it will display Reset OK. and the program
will continue run to the next code.
As the camera got to take photo once PIR Motion Sensor detects the motion of human
or stuff, the program have to continue loop without ending. If any motion within the
range is detected, the if statement will run while if there is no motion detected, the
while loop will also run so that the program is said to be endless unless there is no