Exp5
Exp5
Dalia Kusbeh
03/06/2024
www.lib-go.com
9 Introduction to MBED
environment
To be familiar with MBED software libraries, hardware designs and online or offline
tools for professional rapid prototyping of products based on ARM microcontrollers.
2.Overview
The mbed platform provides free software libraries, hardware designs and online tools for
professional rapid prototyping of products based on ARM microcontrollers.
The platform includes a standards-based C/C++ SDK, a microcontroller HDK and
supported development boards, an online compiler and online developer collaboration
tools.
2.1 Rapid prototyping
• Easy to transfer the object code : USB link, no need of a specific programmer
• Easy to wire on a protoboard : 40 pins DIP package
• Easy to write a program :
• Efficient C++ libraries
• No need to install any software : online development tool
• There is offline development tool
• Community forum and wiki
5V regulator
Motor control
1 chopper (LMD18200)
HMI
2 potentiometers
Analog
Communications
1 Ethernet RJ-45
1 USB host
1 I2C
3.Procedure
Figure 8
This program defines a digital output connected to the LED1. Four blue leds are present on the
MEBD module. They are associated with pins names LED1, LED2, LED3, LED4.
Click compile button. The program is compiled and a binary file is downloaded. Save this file on
the MBED drive. Rest the MBED module. A led is blinking.
Task: Write a code to make the four leds switch on one after the other. First LED1 is
on for 0.2s, then LED2 is on for 0.2s, then LED3 is on for 0.2s …
#include "mbed.h"
#include "TextLCD.h"
We have sent data from the MBED to the PC. Now we will send data from the PC to the MBED.
The member function readable() of Serial class return 1 if there is a character available to read,
0 otherwise. The member function getc() reads the character.
TODO:
Character ‘1’ send by the PC switch on the LED1, and LCD display 1 is received.
Character ‘0’ send by the PC switch of the LED1, and LCD display 1 is received.
Define c as an int and insert and complete this code inside the infinite loop:
If ( pc.readable( ) ) {
C = pc.getc( );
If (c == ‘0’) {
} else if ( c == ‘1’)
….
}
Uploaded by Dalia Kusbeh to Lib-Go.com
www.lib-go.com
Test your code.
Now we will use the interrupt mechanism of Serial class instead of polling the reception.
The method attach(myFunction) of Serial class attach a function to call whenever
character is received.
Create a function receive ( ) which reads and analyzes a received character. Attach the
function receive ( ) to the Serial object pc before the infinite loop: