SlideShare a Scribd company logo
YOONG HOR MENG . yhm2@np.edu.sg . 6460 6717
Ngee Ann Polytechnic 1




Ngee Ann Polytechnic 2
Ngee Ann Polytechnic 3
Ngee Ann Polytechnic 4
Ngee Ann Polytechnic 5
http://www.synvox.ch/lpc1768/lpc1768_mbed_pinout.pdf
Ngee Ann Polytechnic 6
http://mbed.org/handbook/DigitalOut
http://mbed.org/users/yoonghm/notebook/digital-output/
DigitalOut
http://mbed.org/projects/libraries/api/mbed/trunk/wait_api
Ngee Ann Polytechnic 7
Circuit 2
mbed
p5
Circuit 1
+3.3V
mbed
p5
When p5 is LOW (0 V), LED is ON When p5 is HIGH (+3.3 V), LED is ON
What is the use of the resistor?
DigitalOut
Ngee Ann Polytechnic 8
http://ledcalculator.net/
Ngee Ann Polytechnic 9
Digital IO pins are at 3.3 V, 40 mA each, 400 mA maximum total
How do you drive an application with larger current?
http://cq.cx/interface.pl
www.youtube.com/watch?v=Te5YYVZiOKs
Ngee Ann Polytechnic 10
Using BJT Using Darlington Pair Using Darlington Pair
with Relay
Using Power
MOSFET
BusOut
Ngee Ann Polytechnic 11
#include "mbed.h"
#define WAIT_SECOND 0.1
// LSB ... MSB
BusOut Bar(p20, p19, p18, p17, p16,
p15, p14, p13, p12, p11);
DigitalOut Led(LED1);
int main() {
Led = 0;
while(1) {
// Shift from LSB to MSB
for (int i = 0; i < 10; i++) {
Led = !Led;
Bar = 1 << i;
wait(WAIT_SECOND);
}
}
}
BusOut
Ngee Ann Polytechnic 12
#include "mbed.h"
#define WAIT_SECOND 0.1
// LSB ... MSB
BusOut Bar(p20, p19, p18, p17, p16,
p15, p14, p13, p12, p11);
DigitalOut Led(LED1);
int main() {
Led = 0;
while(1) {
// Shift from LSB to MSB
for (int i = 0; i < 10; i++) {
Led = !Led; Bar = 1 << i; wait(WAIT_SECOND);
}
// Shift from MSB to LSB
for (int i = 0; i < 10; i++) {
Led = !Led; Bar = 0x0200 >> i; wait(WAIT_SECOND);
}
}
}
BusOut
Ngee Ann Polytechnic 13
#include "mbed.h"
#define WAIT_SECOND 0.1
// LSB ... MSB
BusOut Bar(p20, p19, p18, p17, p16,
p15, p14, p13, p12, p11);
DigitalOut Led(LED1);
int main() {
Led = 0; Bar = 3;
wait(WAIT_SECOND); // Start from LSB first
while(1) {
// Shift from LSB to MSB
for (int i = 1; i < 10; i++) {
Led = !Led; Bar = 3 << i; wait(WAIT_SECOND);
}
// Shift from MSB to LSB
for (int i = 1; i < 10; i++) {
Led = !Led; Bar = 0x0300 >> i; wait(WAIT_SECOND);
}
}
}
DigitalIn
Ngee Ann Polytechnic 14
http://mbed.org/handbook/DigitalIn
http://mbed.org/users/yoonghm/notebook/digital-input/
Ngee Ann Polytechnic 15
• Pin p5 is pull-up to +3.3 V (HIGH)
• Negligible current flow into pin p5
+3.3V
mbed
p5 S1
• Pin p5 is shorted to ground (LOW)
• Resistor limits the current
// Toggle LED1 when button is pressed
#include "mbed.h"
DigitalIn enable(p5);
DigitalOut myled(LED1);
int main() {
while (1) {
if (!enable) {
myled = !myled;
wait(0.2);
}
}
}
+3.3V
mbed
p5 S1
Ngee Ann Polytechnic 16
// Toggle LED1 when button is pressed
#include "mbed.h"
DigitalIn enable(p5);
DigitalOut myled(LED1);
int main() {
while(1) {
if (enable) {
myled = !myled;
wait(0.2);
}
}
}
• Pin p5 is pull-down to ground (LOW)
+3.3V
mbed
p5 S1
• Pin p5 is connected to +3.3 V (HIGH)
+3.3V
mbed
p5 S1
Ngee Ann Polytechnic 17
• Pin p5 is pull-up to +3.3 V (HIGH) via
internal pull-up resistor
• Pin p5 is shorted to ground (LOW)
• Pull-up resistor limits the current
// Toggle LED1 when button is pressed
#include "mbed.h"
DigitalIn enable(p5);
DigitalOut myled(LED1);
int main()
{
enable.mode(PullUp);
while(1) {
if (!enable) { // p5 is +3.3 V
myled = !myled;
wait(0.2);
}
}
}
mbed
p5 S1
mbed
p5 S1
Ngee Ann Polytechnic 18
• Pin p5 is pull-down to 0 V (LOW)
via internal resistor
• Pin p5 is shorted to 3.3 V (HIGH)
• Internal pull-down resistor limits
the current
// Toggle LED1 when button is pressed
#include "mbed.h"
DigitalIn enable(p5);
DigitalOut myled(LED1);
int main()
{
enable.mode(PullDown);
while(1) {
if (enable) { // p5 is +3.3 V
myled = !myled;
wait(0.2);
}
}
}
+3.3V
mbed
p5 S1
+3.3V
mbed
p5 S1
Ngee Ann Polytechnic 19
ASIC
I/O
Devices
VCCA VCCB
If VccA is not equal to VccB
1. VOH of the driver must be greater than the VIH of the receiver
2. The VOL of the driver must be less than the VIL of the receiver
3. The output voltage from the driver must not exceed the I/O voltage
tolerance of the receiver
Logic Level
Translation
Ngee Ann Polytechnic 20
http://www.nxp.com/documents/application_note/AN240.pdf
Ngee Ann Polytechnic 21
http://mbed.org/handbook/InterruptIn
Interrupt service routine or callback
InterruptIn
Ngee Ann Polytechnic 22
Rising Edge
http://mbed.org/users/AjK/notebook/regarding-interrupts-use-and-blocking/
InterruptIn
InterruptIn


Ngee Ann Polytechnic 23
InterruptIn
Ngee Ann Polytechnic 24
mbed
p5 S1
Example: Intrusion Detection System
p5 goes low when an intrusion is detected
3.3
Voltage
at pin 5
time
0
#include "mbed.h"
InterruptIn intruder(p5);
DigitalOut alarm(LED1);
DigitalOut led(LED2);
void intr() {alarm = 1; }
int main() {
intruder.mode(PullUp);
intruder.fall(&intr);
led = 1; alarm = 0; // no alarm
while (1) {
LPC_SC->PCON = 0x00;
_WFI(); // wait for interrupt
led = !led;
}
}
Ngee Ann Polytechnic 25
#include "mbed.h"
InterruptIn intruder(p5);
DigitalOut alarm(LED1);
void intr() { alarm = 1; }
int main() {
intruder.mode(PullUp);
intruder.fall(&intr);
alarm = 0; // no alarm
while (1) {
LPC_SC->PCON = 0x00;
__wfi(); // wait for interrupt
}
}
#include "mbed.h"
DigitalIn intruder(p5);
DigitalOut alarm(LED1);
int main() {
intruder.mode(PullUp);
alarm = 0; // no alarm
while (1) {
if (intruder == 0) {
alarm = 1;
}
}
}
InterruptIn

printf() malloc()
new()
 wait()

 __disable_irq()
__enable_irq()
Ngee Ann Polytechnic 26
Ngee Ann Polytechnic 27
http://mbed.org/handbook/Debugging
printf(...) – Print out message on a PC terminal via USB
error(...) – Print out message on a PC terminal via USB and stop
Onboard LEDs blink blue in a distinctive pattern
when it encounters run time error
The program will stop running
You need the following software as stated in
http://mbed.org/handbook/Windows-serial-configuration
http://www.extraputty.com/
Ngee Ann Polytechnic 28
#include "mbed.h"
DigitalOut myled1(LED1);
DigitalOut myled2(LED2);
int main() {
int i = 5;
printf("Hi!n");
while (i--) {
myled1 = !myled1;
wait(0.25);
}
printf("Alive!n");
while (1) {
myled2 = !myled2;
wait(0.25);
}
}
#include "mbed.h"
DigitalOut myled1(LED1);
DigitalOut myled2(LED2);
int main() {
int i = 5;
printf("Hi!n");
while (i--) {
myled1 = !myled1;
wait(0.25);
}
error("Dead!n");
while (1) {
myled2 = !myled2;
wait(0.25);
}
}
Timer
Ngee Ann Polytechnic 29
http://mbed.org/handbook/Timer
Ngee Ann Polytechnic 30
Timer
Timeout
Ngee Ann Polytechnic 31
http://mbed.org/handbook/Timeout
Timeout
Ngee Ann Polytechnic 32
Ticker
Ngee Ann Polytechnic 33
http://mbed.org/handbook/Ticker
Ngee Ann Polytechnic 34
Ticker
Ngee Ann Polytechnic 35
AnalogIn
http://mbed.org/handbook/AnalogIn
http://mbed.org/users/yoonghm/notebook/analog-input/
Ngee Ann Polytechnic 36
AnalogIn



Ngee Ann Polytechnic 37



Ngee Ann Polytechnic 38


Ngee Ann Polytechnic 39
Ngee Ann Polytechnic 40
mbed
p20
GND
R1
R2
#include "mbed.h"
AnalogIn ain1(p20);
AnalogIn ain2(p19);
float vtotal;
float vr2;
int main() {
while (1){
vr2 = ain1.read() * 3.3;
vtotal = ain2.read() * 3.3;
printf("VR1 = %f ", vtotal - vr2);
printf("VR2 = %f ", vr2);
printf("VTotal= %fn", vtotal);
wait(1.0);
}
}
VOUT
p19




Ngee Ann Polytechnic 41
mbed p20
GND
220 
100 
+5V
Ngee Ann Polytechnic 42
AnalogOut
http://mbed.org/handbook/AnalogOut
http://mbed.org/users/yoonghm/notebook/analog-output/
Change wait(0.0001) to wait(0.001) to see effect faster
Ngee Ann Polytechnic 43
AnalogOut
Ngee Ann Polytechnic 44
TextLCD
http://mbed.org/cookbook/Text-LCD
LCD mbed
Pin Number Pin Name Pin Number Pin Name
1 GND 1 GND
2 VCC 39 VU
3 VO 1 GND
4 RS 15 p15
5 RW 1 GND
6 E 16 p16
7 D0 Not Connected
8 D1 Not Connected
9 D2 Not Connected
10 D3 Not Connected
11 D4 17 p17
12 D5 18 p18
13 D6 19 p19
14 D7 20 p20
15 LED+ 39 VU
16 LED- 1 GND
Ngee Ann Polytechnic 45
TextLCD
 PWM1 PWM6




Ngee Ann Polytechnic 46
PwmOut
Ngee Ann Polytechnic 47
W = Pulse Width
T = Period
D = Duty cycle
Ngee Ann Polytechnic 48
PwmOut
The default period is 0.020s, pulse width is 0
PwmOut
 LED1 LED4 PwmOut


Ngee Ann Polytechnic 49
PwmOut
Ngee Ann Polytechnic 50
#include "mbed.h"
PwmOut led1(LED1);
PwmOut led2(LED2);
PwmOut led3(LED3);
PwmOut led4(LED4);
int main()
{
while (1) {
for (float f = 0.0; f < 1.0; f += 0.001) {
led1 = f;
led2 = f * f;
led3 = (f + 1.0) / 2.0;
led4 = 1.0 - f;
wait(0.01);
}
}
}
Take note that
• All LEDs are assigned values
from 0.0 to 1.0
• The brightness of the LEDs color
changed abruptly
PwmOut
Ngee Ann Polytechnic 51
#include "mbed.h"
#include <math.h>
#ifndef M_PI
#define M_PI 3.1415
#endif
PwmOut led1(LED1);
PwmOut led2(LED2);
PwmOut led3(LED3);
PwmOut led4(LED4);
int main()
{
float f = 0.0;
while (1) {
Take note that
• Using 4 sinusoidal waveforms, spaced 90o apart, the
brightness of the LEDs varies smoothly
• M_PI is a constant in <math.h> which is not defined in
the C library from mbed.org
• All sinusoidal values are computed dynamically only when
it is needed. It is a bit CPU intensive
// Add 1.0 to ensure all values are positive
led1 = sin( (f ) * M_PI / 180.0) + 1.0;
led2 = sin( (f + 90.0) * M_PI / 180.0) + 1.0;
led3 = sin( (f + 180.0) * M_PI / 180.0) + 1.0;
led4 = sin( (f + 270.0) * M_PI / 180.0) + 1.0;
f += 1.0;
wait(0.01);
}
}
PwmOut
Ngee Ann Polytechnic 52
#include "mbed.h"
#include <math.h>
#ifndef M_PI
#define M_PI 3.1415
#endif
#define STP 256 /* Step */
#define LED 4 /* Number of LEDs
int main()
{
PwmOut Leds[] = {(LED1), (LED2), (LED3), (LED4)};
float y[STP][LED]; // Store all values
float res = 360 / STP; // Resolution (degree per step)
float x = 0.0; // Current x
float ph = 360 / LED; // Phase different btw two successive LEDs
for (int i = 0; i < STP; i++) {
for (int j = 0; j < LED; j++) {
y[i][j] = sin( (x + ph * j) * M_PI / 180.0) + 1.0;
}
x += res; // increment x by each resolution
}
Ngee Ann Polytechnic 53
while (1) {
for (int i = 0; i < STP; i++) {
for (int j = 0; j < LED; j++) {
Leds[j] = y[i][j];
}
count++;
wait(0.01);
}
}
}
PwmOut
Take note that
• The code above run significantly faster than pervious example but consume slightly
more memory in flash and RAM

1. RX
2. TX
3. GND

 Start Stop
Ngee Ann Polytechnic 54
8-bit Data Byte
Parity
Stop
Start
Optional


Ngee Ann Polytechnic 55
Space Space
Mark
Time
Voltage
+25V
+3V
-3V
-25V
Logic '0'
Logic '1'
Transition Region
 Vcc

Ngee Ann Polytechnic 56
Space Space
Mark
Time
Voltage
Vcc
V1H
V0L
Logic '0'
Logic '1'
Transition Region
0
Ngee Ann Polytechnic 57
+5 V
+15 V
-15 V
t
t
1 0 0 1 1 1 1 10 0 0 0
Idle Start B0 B1 B3 B6 Stop IdleB2 B4 B5 B7
Transmission of the letter ‘J’ from μC to PC
Logic value
Meaning
Signal level at the μC output pin (TX)
Signal level at the PC input pin (RX)
ASCII character ‘J’ is
represented by
• 0x4A or
• 01001010
μC PC
LevelShifter
TX
RX
RX
TX
TX
RX
RX
TX
LSB MSB
LSBMSB
Serial
Ngee Ann Polytechnic 58
mbed Device
p9(TX)
p10(RX)
RX
TX
PC
USB
Serial
Ngee Ann Polytechnic 59
Ngee Ann Polytechnic 60
http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm
Ngee Ann Polytechnic 61
Ngee Ann Polytechnic 62
If both devices are from the same
power source, use CMOS Output.
In this case, the input current to the
microcontroller is actually taken from
the +3V, and via the Source terminal
of the MOSFET of the OUT pin of the
Voltage Detector.
If both devices are from different power
sources, use Open Drain Output.
In this case, the input current to the
microcontroller is actually taken from
+5V, and via the Drain terminal of the N-
channel MOSFET of the OUT pin of the
Voltage Detector. A resistor is necessary
to reduce the amount of current drawn.
Ngee Ann Polytechnic 63

More Related Content

What's hot

Arm cortex-m4 programmer model
Arm cortex-m4 programmer modelArm cortex-m4 programmer model
Arm cortex-m4 programmer model
Mohammed Gomaa
 
WN Memory Tiering WP Mar2023.pdf
WN Memory Tiering WP Mar2023.pdfWN Memory Tiering WP Mar2023.pdf
WN Memory Tiering WP Mar2023.pdf
RochanSankar1
 
INTEL’S MMX TECHNOLOGY FOR ENHANCED PROCESSOR
INTEL’S MMX TECHNOLOGY FOR ENHANCED PROCESSORINTEL’S MMX TECHNOLOGY FOR ENHANCED PROCESSOR
INTEL’S MMX TECHNOLOGY FOR ENHANCED PROCESSOR
Nikhil Musham
 
Virtual keyboard abstract
Virtual keyboard abstractVirtual keyboard abstract
Virtual keyboard abstract
sri sudheera chitipolu
 
Summary - Adaptive Insertion Policies for High Performance Caching. Qureshi, ...
Summary - Adaptive Insertion Policies for High Performance Caching. Qureshi, ...Summary - Adaptive Insertion Policies for High Performance Caching. Qureshi, ...
Summary - Adaptive Insertion Policies for High Performance Caching. Qureshi, ...
Jose Pinilla
 
Internet of things (IOT) Presentation-PPT
Internet of things (IOT) Presentation-PPTInternet of things (IOT) Presentation-PPT
Internet of things (IOT) Presentation-PPT
Charan Vimala
 
Risc and cisc casestudy
Risc and cisc casestudyRisc and cisc casestudy
Risc and cisc casestudy
jvs71294
 
Wi-Fi Esp8266 nodemcu
Wi-Fi Esp8266 nodemcu Wi-Fi Esp8266 nodemcu
Wi-Fi Esp8266 nodemcu
creatjet3d labs
 
Iot and Healthcare ppt
Iot and Healthcare pptIot and Healthcare ppt
Iot and Healthcare ppt
Armaan Farshori
 
Ec8791 arm 9 processor
Ec8791 arm 9 processorEc8791 arm 9 processor
Ec8791 arm 9 processor
RajalakshmiSermadurai
 
Compare Performance-power of Arm Cortex vs RISC-V for AI applications_oct_2021
Compare Performance-power of Arm Cortex vs RISC-V for AI applications_oct_2021Compare Performance-power of Arm Cortex vs RISC-V for AI applications_oct_2021
Compare Performance-power of Arm Cortex vs RISC-V for AI applications_oct_2021
Deepak Shankar
 
Architecture Exploration of RISC-V Processor and Comparison with ARM Cortex-A53
Architecture Exploration of RISC-V Processor and Comparison with ARM Cortex-A53Architecture Exploration of RISC-V Processor and Comparison with ARM Cortex-A53
Architecture Exploration of RISC-V Processor and Comparison with ARM Cortex-A53
KarthiSugumar
 
Temperature Controlled Fan Project
Temperature Controlled Fan ProjectTemperature Controlled Fan Project
Temperature Controlled Fan Project
Aditya Ratnaparkhi
 
IOT Network architecture and Design.pptx
IOT Network architecture and Design.pptxIOT Network architecture and Design.pptx
IOT Network architecture and Design.pptx
MeghaShree665225
 
Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Introduction to AVR Microcontroller
Introduction to AVR Microcontroller
Mahmoud Sadat
 
2 introduction to arm architecture
2 introduction to arm architecture2 introduction to arm architecture
2 introduction to arm architecturesatish1jisatishji
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduino
Santosh Verma
 
Introduction to Internet of Things (IoT)
Introduction to Internet of Things (IoT)Introduction to Internet of Things (IoT)
Introduction to Internet of Things (IoT)
Amarjeetsingh Thakur
 

What's hot (20)

Arm cortex-m4 programmer model
Arm cortex-m4 programmer modelArm cortex-m4 programmer model
Arm cortex-m4 programmer model
 
WN Memory Tiering WP Mar2023.pdf
WN Memory Tiering WP Mar2023.pdfWN Memory Tiering WP Mar2023.pdf
WN Memory Tiering WP Mar2023.pdf
 
INTEL’S MMX TECHNOLOGY FOR ENHANCED PROCESSOR
INTEL’S MMX TECHNOLOGY FOR ENHANCED PROCESSORINTEL’S MMX TECHNOLOGY FOR ENHANCED PROCESSOR
INTEL’S MMX TECHNOLOGY FOR ENHANCED PROCESSOR
 
Virtual keyboard abstract
Virtual keyboard abstractVirtual keyboard abstract
Virtual keyboard abstract
 
Summary - Adaptive Insertion Policies for High Performance Caching. Qureshi, ...
Summary - Adaptive Insertion Policies for High Performance Caching. Qureshi, ...Summary - Adaptive Insertion Policies for High Performance Caching. Qureshi, ...
Summary - Adaptive Insertion Policies for High Performance Caching. Qureshi, ...
 
Internet of things (IOT) Presentation-PPT
Internet of things (IOT) Presentation-PPTInternet of things (IOT) Presentation-PPT
Internet of things (IOT) Presentation-PPT
 
Risc and cisc casestudy
Risc and cisc casestudyRisc and cisc casestudy
Risc and cisc casestudy
 
Topics
TopicsTopics
Topics
 
Wi-Fi Esp8266 nodemcu
Wi-Fi Esp8266 nodemcu Wi-Fi Esp8266 nodemcu
Wi-Fi Esp8266 nodemcu
 
Iot and Healthcare ppt
Iot and Healthcare pptIot and Healthcare ppt
Iot and Healthcare ppt
 
Ec8791 arm 9 processor
Ec8791 arm 9 processorEc8791 arm 9 processor
Ec8791 arm 9 processor
 
Compare Performance-power of Arm Cortex vs RISC-V for AI applications_oct_2021
Compare Performance-power of Arm Cortex vs RISC-V for AI applications_oct_2021Compare Performance-power of Arm Cortex vs RISC-V for AI applications_oct_2021
Compare Performance-power of Arm Cortex vs RISC-V for AI applications_oct_2021
 
Iot ppt
Iot pptIot ppt
Iot ppt
 
Architecture Exploration of RISC-V Processor and Comparison with ARM Cortex-A53
Architecture Exploration of RISC-V Processor and Comparison with ARM Cortex-A53Architecture Exploration of RISC-V Processor and Comparison with ARM Cortex-A53
Architecture Exploration of RISC-V Processor and Comparison with ARM Cortex-A53
 
Temperature Controlled Fan Project
Temperature Controlled Fan ProjectTemperature Controlled Fan Project
Temperature Controlled Fan Project
 
IOT Network architecture and Design.pptx
IOT Network architecture and Design.pptxIOT Network architecture and Design.pptx
IOT Network architecture and Design.pptx
 
Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Introduction to AVR Microcontroller
Introduction to AVR Microcontroller
 
2 introduction to arm architecture
2 introduction to arm architecture2 introduction to arm architecture
2 introduction to arm architecture
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduino
 
Introduction to Internet of Things (IoT)
Introduction to Internet of Things (IoT)Introduction to Internet of Things (IoT)
Introduction to Internet of Things (IoT)
 

Viewers also liked

Up and running with Teensy 3.1
Up and running with Teensy 3.1Up and running with Teensy 3.1
Up and running with Teensy 3.1
yoonghm
 
mbed LPC1768 Pin配置
mbed LPC1768 Pin配置mbed LPC1768 Pin配置
mbed LPC1768 Pin配置
Tsuyoshi Horigome
 
ARM Cortex-M3 Training
ARM Cortex-M3 TrainingARM Cortex-M3 Training
ARM Cortex-M3 Training
Raghav Nayak
 
Tutorial1: mbed開發快速上手
Tutorial1: mbed開發快速上手Tutorial1: mbed開發快速上手
Tutorial1: mbed開發快速上手
艾鍗科技
 
Embedded systems basics
Embedded systems basicsEmbedded systems basics
Embedded systems basics
Mathivanan Natarajan
 
Building IoT devices with ARM mbed - RISE Manchester
Building IoT devices with ARM mbed - RISE ManchesterBuilding IoT devices with ARM mbed - RISE Manchester
Building IoT devices with ARM mbed - RISE Manchester
Jan Jongboom
 
mbed Connect Asia 2016 David Morning Welcome and Kickoff
mbed Connect Asia 2016 David Morning Welcome and Kickoffmbed Connect Asia 2016 David Morning Welcome and Kickoff
mbed Connect Asia 2016 David Morning Welcome and Kickoff
armmbed
 
mbed Connect Asia 2016 Developing IoT devices with mbed OS 5
mbed Connect Asia 2016 Developing IoT devices with mbed OS 5mbed Connect Asia 2016 Developing IoT devices with mbed OS 5
mbed Connect Asia 2016 Developing IoT devices with mbed OS 5
armmbed
 
Crypto Performance on ARM Cortex-M Processors
Crypto Performance on ARM Cortex-M ProcessorsCrypto Performance on ARM Cortex-M Processors
Crypto Performance on ARM Cortex-M Processors
Hannes Tschofenig
 
mbed Connect Asia 2016 Securing IoT with the ARM mbed ecosystem
mbed Connect Asia 2016 Securing IoT with the ARM mbed ecosystemmbed Connect Asia 2016 Securing IoT with the ARM mbed ecosystem
mbed Connect Asia 2016 Securing IoT with the ARM mbed ecosystem
armmbed
 
SPEED CONTROL OF INDUCTION MACHINE WITH REDUCTION IN TORQUE RIPPLE USING ROBU...
SPEED CONTROL OF INDUCTION MACHINE WITH REDUCTION IN TORQUE RIPPLE USING ROBU...SPEED CONTROL OF INDUCTION MACHINE WITH REDUCTION IN TORQUE RIPPLE USING ROBU...
SPEED CONTROL OF INDUCTION MACHINE WITH REDUCTION IN TORQUE RIPPLE USING ROBU...
IAEME Publication
 
Introduction to the extended essay for supervisors
Introduction to the extended essay for supervisorsIntroduction to the extended essay for supervisors
Introduction to the extended essay for supervisors
lindatw
 
STM32 F4 (PWM,SPI And ADC Test Examples)
STM32 F4 (PWM,SPI And ADC Test Examples)STM32 F4 (PWM,SPI And ADC Test Examples)
STM32 F4 (PWM,SPI And ADC Test Examples)
Aymen Lachkhem
 
2nd ARM Developer Day - mbed Workshop - ARM
2nd ARM Developer Day - mbed Workshop - ARM2nd ARM Developer Day - mbed Workshop - ARM
2nd ARM Developer Day - mbed Workshop - ARMAntonio Mondragon
 
HEALTH MONITORING SYSTEM using mbed NXP LPC11U24
HEALTH MONITORING SYSTEM using mbed NXP LPC11U24HEALTH MONITORING SYSTEM using mbed NXP LPC11U24
HEALTH MONITORING SYSTEM using mbed NXP LPC11U24
Jigyasa Singh
 
présentation STM32
présentation STM32présentation STM32
présentation STM32
hatem ben tayeb
 

Viewers also liked (20)

Up and running with Teensy 3.1
Up and running with Teensy 3.1Up and running with Teensy 3.1
Up and running with Teensy 3.1
 
Lpc1768
Lpc1768Lpc1768
Lpc1768
 
mbed LPC1768 Pin配置
mbed LPC1768 Pin配置mbed LPC1768 Pin配置
mbed LPC1768 Pin配置
 
ARM Cortex-M3 Training
ARM Cortex-M3 TrainingARM Cortex-M3 Training
ARM Cortex-M3 Training
 
Tutorial1: mbed開發快速上手
Tutorial1: mbed開發快速上手Tutorial1: mbed開發快速上手
Tutorial1: mbed開發快速上手
 
Embedded systems basics
Embedded systems basicsEmbedded systems basics
Embedded systems basics
 
Building IoT devices with ARM mbed - RISE Manchester
Building IoT devices with ARM mbed - RISE ManchesterBuilding IoT devices with ARM mbed - RISE Manchester
Building IoT devices with ARM mbed - RISE Manchester
 
Presentation
PresentationPresentation
Presentation
 
mbed Connect Asia 2016 David Morning Welcome and Kickoff
mbed Connect Asia 2016 David Morning Welcome and Kickoffmbed Connect Asia 2016 David Morning Welcome and Kickoff
mbed Connect Asia 2016 David Morning Welcome and Kickoff
 
mbed Connect Asia 2016 Developing IoT devices with mbed OS 5
mbed Connect Asia 2016 Developing IoT devices with mbed OS 5mbed Connect Asia 2016 Developing IoT devices with mbed OS 5
mbed Connect Asia 2016 Developing IoT devices with mbed OS 5
 
Crypto Performance on ARM Cortex-M Processors
Crypto Performance on ARM Cortex-M ProcessorsCrypto Performance on ARM Cortex-M Processors
Crypto Performance on ARM Cortex-M Processors
 
mbed Connect Asia 2016 Securing IoT with the ARM mbed ecosystem
mbed Connect Asia 2016 Securing IoT with the ARM mbed ecosystemmbed Connect Asia 2016 Securing IoT with the ARM mbed ecosystem
mbed Connect Asia 2016 Securing IoT with the ARM mbed ecosystem
 
SPEED CONTROL OF INDUCTION MACHINE WITH REDUCTION IN TORQUE RIPPLE USING ROBU...
SPEED CONTROL OF INDUCTION MACHINE WITH REDUCTION IN TORQUE RIPPLE USING ROBU...SPEED CONTROL OF INDUCTION MACHINE WITH REDUCTION IN TORQUE RIPPLE USING ROBU...
SPEED CONTROL OF INDUCTION MACHINE WITH REDUCTION IN TORQUE RIPPLE USING ROBU...
 
5 geo 2º bim
5 geo 2º bim5 geo 2º bim
5 geo 2º bim
 
Introduction to the extended essay for supervisors
Introduction to the extended essay for supervisorsIntroduction to the extended essay for supervisors
Introduction to the extended essay for supervisors
 
STM32 F4 (PWM,SPI And ADC Test Examples)
STM32 F4 (PWM,SPI And ADC Test Examples)STM32 F4 (PWM,SPI And ADC Test Examples)
STM32 F4 (PWM,SPI And ADC Test Examples)
 
2nd ARM Developer Day - mbed Workshop - ARM
2nd ARM Developer Day - mbed Workshop - ARM2nd ARM Developer Day - mbed Workshop - ARM
2nd ARM Developer Day - mbed Workshop - ARM
 
HEALTH MONITORING SYSTEM using mbed NXP LPC11U24
HEALTH MONITORING SYSTEM using mbed NXP LPC11U24HEALTH MONITORING SYSTEM using mbed NXP LPC11U24
HEALTH MONITORING SYSTEM using mbed NXP LPC11U24
 
présentation STM32
présentation STM32présentation STM32
présentation STM32
 
Design Report
Design ReportDesign Report
Design Report
 

Similar to Power the world with mbed LPC1768

Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manual
twinkleratna
 
Remote ashok
Remote ashokRemote ashok
Remote ashok
Ashokkumar sekar
 
Practical file
Practical filePractical file
Practical file
rajeevkr35
 
Arm7 Interfacing examples
Arm7   Interfacing examples Arm7   Interfacing examples
Arm7 Interfacing examples
Dr.YNM
 
Bidirect visitor counter
Bidirect visitor counterBidirect visitor counter
Bidirect visitor counter
Electric&elctronics&engineeering
 
Intro2 Robotic With Pic18
Intro2 Robotic With Pic18Intro2 Robotic With Pic18
Intro2 Robotic With Pic18
Moayadhn
 
01 GPIO||General Purpose Input Output.2016
01 GPIO||General Purpose Input Output.201601 GPIO||General Purpose Input Output.2016
01 GPIO||General Purpose Input Output.2016
Mohamed Fawzy
 
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...
IRJET Journal
 
Gain Experience with GPIO, LED Interface and Functions in TI TIVA C Launchpad...
Gain Experience with GPIO, LED Interface and Functions in TI TIVA C Launchpad...Gain Experience with GPIO, LED Interface and Functions in TI TIVA C Launchpad...
Gain Experience with GPIO, LED Interface and Functions in TI TIVA C Launchpad...
nipunkrn
 
Scottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RADScottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RAD
lostcaggy
 
Arduino tutorial A to Z
Arduino tutorial A to ZArduino tutorial A to Z
Arduino tutorial A to Z
Md. Asaduzzaman Jabin
 
Arduino اردوينو
Arduino اردوينوArduino اردوينو
Arduino اردوينو
salih mahmod
 
I made some more expansion board for M5Stack
I made some more expansion  board for M5StackI made some more expansion  board for M5Stack
I made some more expansion board for M5Stack
Masawo Yamazaki
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
Mujahid Hussain
 
Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
Ariel Tonatiuh Espindola
 
8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt
notagain0712
 
Logic gate tester for IC's ( Digital Electronics and Logic deisgn EE3114 )
Logic gate tester for IC's ( Digital Electronics and Logic deisgn EE3114 )Logic gate tester for IC's ( Digital Electronics and Logic deisgn EE3114 )
Logic gate tester for IC's ( Digital Electronics and Logic deisgn EE3114 )
Jikrul Sayeed
 

Similar to Power the world with mbed LPC1768 (20)

Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manual
 
Anup2
Anup2Anup2
Anup2
 
Remote ashok
Remote ashokRemote ashok
Remote ashok
 
Jp
Jp Jp
Jp
 
Practical file
Practical filePractical file
Practical file
 
Arm7 Interfacing examples
Arm7   Interfacing examples Arm7   Interfacing examples
Arm7 Interfacing examples
 
Bidirect visitor counter
Bidirect visitor counterBidirect visitor counter
Bidirect visitor counter
 
Intro2 Robotic With Pic18
Intro2 Robotic With Pic18Intro2 Robotic With Pic18
Intro2 Robotic With Pic18
 
01 GPIO||General Purpose Input Output.2016
01 GPIO||General Purpose Input Output.201601 GPIO||General Purpose Input Output.2016
01 GPIO||General Purpose Input Output.2016
 
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...
 
Gain Experience with GPIO, LED Interface and Functions in TI TIVA C Launchpad...
Gain Experience with GPIO, LED Interface and Functions in TI TIVA C Launchpad...Gain Experience with GPIO, LED Interface and Functions in TI TIVA C Launchpad...
Gain Experience with GPIO, LED Interface and Functions in TI TIVA C Launchpad...
 
Scottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RADScottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RAD
 
Arduino tutorial A to Z
Arduino tutorial A to ZArduino tutorial A to Z
Arduino tutorial A to Z
 
Arduino اردوينو
Arduino اردوينوArduino اردوينو
Arduino اردوينو
 
I made some more expansion board for M5Stack
I made some more expansion  board for M5StackI made some more expansion  board for M5Stack
I made some more expansion board for M5Stack
 
Final Presentation
Final PresentationFinal Presentation
Final Presentation
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
 
Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
 
8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt
 
Logic gate tester for IC's ( Digital Electronics and Logic deisgn EE3114 )
Logic gate tester for IC's ( Digital Electronics and Logic deisgn EE3114 )Logic gate tester for IC's ( Digital Electronics and Logic deisgn EE3114 )
Logic gate tester for IC's ( Digital Electronics and Logic deisgn EE3114 )
 

Recently uploaded

在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 

Recently uploaded (20)

在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 

Power the world with mbed LPC1768

  • 1. YOONG HOR MENG . yhm2@np.edu.sg . 6460 6717 Ngee Ann Polytechnic 1
  • 5. Ngee Ann Polytechnic 5 http://www.synvox.ch/lpc1768/lpc1768_mbed_pinout.pdf
  • 6. Ngee Ann Polytechnic 6 http://mbed.org/handbook/DigitalOut http://mbed.org/users/yoonghm/notebook/digital-output/ DigitalOut http://mbed.org/projects/libraries/api/mbed/trunk/wait_api
  • 7. Ngee Ann Polytechnic 7 Circuit 2 mbed p5 Circuit 1 +3.3V mbed p5 When p5 is LOW (0 V), LED is ON When p5 is HIGH (+3.3 V), LED is ON What is the use of the resistor? DigitalOut
  • 8. Ngee Ann Polytechnic 8 http://ledcalculator.net/
  • 9. Ngee Ann Polytechnic 9 Digital IO pins are at 3.3 V, 40 mA each, 400 mA maximum total How do you drive an application with larger current? http://cq.cx/interface.pl www.youtube.com/watch?v=Te5YYVZiOKs
  • 10. Ngee Ann Polytechnic 10 Using BJT Using Darlington Pair Using Darlington Pair with Relay Using Power MOSFET
  • 11. BusOut Ngee Ann Polytechnic 11 #include "mbed.h" #define WAIT_SECOND 0.1 // LSB ... MSB BusOut Bar(p20, p19, p18, p17, p16, p15, p14, p13, p12, p11); DigitalOut Led(LED1); int main() { Led = 0; while(1) { // Shift from LSB to MSB for (int i = 0; i < 10; i++) { Led = !Led; Bar = 1 << i; wait(WAIT_SECOND); } } }
  • 12. BusOut Ngee Ann Polytechnic 12 #include "mbed.h" #define WAIT_SECOND 0.1 // LSB ... MSB BusOut Bar(p20, p19, p18, p17, p16, p15, p14, p13, p12, p11); DigitalOut Led(LED1); int main() { Led = 0; while(1) { // Shift from LSB to MSB for (int i = 0; i < 10; i++) { Led = !Led; Bar = 1 << i; wait(WAIT_SECOND); } // Shift from MSB to LSB for (int i = 0; i < 10; i++) { Led = !Led; Bar = 0x0200 >> i; wait(WAIT_SECOND); } } }
  • 13. BusOut Ngee Ann Polytechnic 13 #include "mbed.h" #define WAIT_SECOND 0.1 // LSB ... MSB BusOut Bar(p20, p19, p18, p17, p16, p15, p14, p13, p12, p11); DigitalOut Led(LED1); int main() { Led = 0; Bar = 3; wait(WAIT_SECOND); // Start from LSB first while(1) { // Shift from LSB to MSB for (int i = 1; i < 10; i++) { Led = !Led; Bar = 3 << i; wait(WAIT_SECOND); } // Shift from MSB to LSB for (int i = 1; i < 10; i++) { Led = !Led; Bar = 0x0300 >> i; wait(WAIT_SECOND); } } }
  • 14. DigitalIn Ngee Ann Polytechnic 14 http://mbed.org/handbook/DigitalIn http://mbed.org/users/yoonghm/notebook/digital-input/
  • 15. Ngee Ann Polytechnic 15 • Pin p5 is pull-up to +3.3 V (HIGH) • Negligible current flow into pin p5 +3.3V mbed p5 S1 • Pin p5 is shorted to ground (LOW) • Resistor limits the current // Toggle LED1 when button is pressed #include "mbed.h" DigitalIn enable(p5); DigitalOut myled(LED1); int main() { while (1) { if (!enable) { myled = !myled; wait(0.2); } } } +3.3V mbed p5 S1
  • 16. Ngee Ann Polytechnic 16 // Toggle LED1 when button is pressed #include "mbed.h" DigitalIn enable(p5); DigitalOut myled(LED1); int main() { while(1) { if (enable) { myled = !myled; wait(0.2); } } } • Pin p5 is pull-down to ground (LOW) +3.3V mbed p5 S1 • Pin p5 is connected to +3.3 V (HIGH) +3.3V mbed p5 S1
  • 17. Ngee Ann Polytechnic 17 • Pin p5 is pull-up to +3.3 V (HIGH) via internal pull-up resistor • Pin p5 is shorted to ground (LOW) • Pull-up resistor limits the current // Toggle LED1 when button is pressed #include "mbed.h" DigitalIn enable(p5); DigitalOut myled(LED1); int main() { enable.mode(PullUp); while(1) { if (!enable) { // p5 is +3.3 V myled = !myled; wait(0.2); } } } mbed p5 S1 mbed p5 S1
  • 18. Ngee Ann Polytechnic 18 • Pin p5 is pull-down to 0 V (LOW) via internal resistor • Pin p5 is shorted to 3.3 V (HIGH) • Internal pull-down resistor limits the current // Toggle LED1 when button is pressed #include "mbed.h" DigitalIn enable(p5); DigitalOut myled(LED1); int main() { enable.mode(PullDown); while(1) { if (enable) { // p5 is +3.3 V myled = !myled; wait(0.2); } } } +3.3V mbed p5 S1 +3.3V mbed p5 S1
  • 19. Ngee Ann Polytechnic 19 ASIC I/O Devices VCCA VCCB If VccA is not equal to VccB 1. VOH of the driver must be greater than the VIH of the receiver 2. The VOL of the driver must be less than the VIL of the receiver 3. The output voltage from the driver must not exceed the I/O voltage tolerance of the receiver Logic Level Translation
  • 20. Ngee Ann Polytechnic 20 http://www.nxp.com/documents/application_note/AN240.pdf
  • 21. Ngee Ann Polytechnic 21 http://mbed.org/handbook/InterruptIn Interrupt service routine or callback InterruptIn
  • 22. Ngee Ann Polytechnic 22 Rising Edge http://mbed.org/users/AjK/notebook/regarding-interrupts-use-and-blocking/ InterruptIn
  • 24. InterruptIn Ngee Ann Polytechnic 24 mbed p5 S1 Example: Intrusion Detection System p5 goes low when an intrusion is detected 3.3 Voltage at pin 5 time 0 #include "mbed.h" InterruptIn intruder(p5); DigitalOut alarm(LED1); DigitalOut led(LED2); void intr() {alarm = 1; } int main() { intruder.mode(PullUp); intruder.fall(&intr); led = 1; alarm = 0; // no alarm while (1) { LPC_SC->PCON = 0x00; _WFI(); // wait for interrupt led = !led; } }
  • 25. Ngee Ann Polytechnic 25 #include "mbed.h" InterruptIn intruder(p5); DigitalOut alarm(LED1); void intr() { alarm = 1; } int main() { intruder.mode(PullUp); intruder.fall(&intr); alarm = 0; // no alarm while (1) { LPC_SC->PCON = 0x00; __wfi(); // wait for interrupt } } #include "mbed.h" DigitalIn intruder(p5); DigitalOut alarm(LED1); int main() { intruder.mode(PullUp); alarm = 0; // no alarm while (1) { if (intruder == 0) { alarm = 1; } } }
  • 26. InterruptIn  printf() malloc() new()  wait()   __disable_irq() __enable_irq() Ngee Ann Polytechnic 26
  • 27. Ngee Ann Polytechnic 27 http://mbed.org/handbook/Debugging printf(...) – Print out message on a PC terminal via USB error(...) – Print out message on a PC terminal via USB and stop Onboard LEDs blink blue in a distinctive pattern when it encounters run time error The program will stop running You need the following software as stated in http://mbed.org/handbook/Windows-serial-configuration http://www.extraputty.com/
  • 28. Ngee Ann Polytechnic 28 #include "mbed.h" DigitalOut myled1(LED1); DigitalOut myled2(LED2); int main() { int i = 5; printf("Hi!n"); while (i--) { myled1 = !myled1; wait(0.25); } printf("Alive!n"); while (1) { myled2 = !myled2; wait(0.25); } } #include "mbed.h" DigitalOut myled1(LED1); DigitalOut myled2(LED2); int main() { int i = 5; printf("Hi!n"); while (i--) { myled1 = !myled1; wait(0.25); } error("Dead!n"); while (1) { myled2 = !myled2; wait(0.25); } }
  • 29. Timer Ngee Ann Polytechnic 29 http://mbed.org/handbook/Timer
  • 31. Timeout Ngee Ann Polytechnic 31 http://mbed.org/handbook/Timeout
  • 33. Ticker Ngee Ann Polytechnic 33 http://mbed.org/handbook/Ticker
  • 34. Ngee Ann Polytechnic 34 Ticker
  • 35. Ngee Ann Polytechnic 35 AnalogIn http://mbed.org/handbook/AnalogIn http://mbed.org/users/yoonghm/notebook/analog-input/
  • 36. Ngee Ann Polytechnic 36 AnalogIn
  • 40. Ngee Ann Polytechnic 40 mbed p20 GND R1 R2 #include "mbed.h" AnalogIn ain1(p20); AnalogIn ain2(p19); float vtotal; float vr2; int main() { while (1){ vr2 = ain1.read() * 3.3; vtotal = ain2.read() * 3.3; printf("VR1 = %f ", vtotal - vr2); printf("VR2 = %f ", vr2); printf("VTotal= %fn", vtotal); wait(1.0); } } VOUT p19
  • 41.     Ngee Ann Polytechnic 41 mbed p20 GND 220  100  +5V
  • 42. Ngee Ann Polytechnic 42 AnalogOut http://mbed.org/handbook/AnalogOut http://mbed.org/users/yoonghm/notebook/analog-output/ Change wait(0.0001) to wait(0.001) to see effect faster
  • 43. Ngee Ann Polytechnic 43 AnalogOut
  • 44. Ngee Ann Polytechnic 44 TextLCD http://mbed.org/cookbook/Text-LCD LCD mbed Pin Number Pin Name Pin Number Pin Name 1 GND 1 GND 2 VCC 39 VU 3 VO 1 GND 4 RS 15 p15 5 RW 1 GND 6 E 16 p16 7 D0 Not Connected 8 D1 Not Connected 9 D2 Not Connected 10 D3 Not Connected 11 D4 17 p17 12 D5 18 p18 13 D6 19 p19 14 D7 20 p20 15 LED+ 39 VU 16 LED- 1 GND
  • 45. Ngee Ann Polytechnic 45 TextLCD
  • 47. PwmOut Ngee Ann Polytechnic 47 W = Pulse Width T = Period D = Duty cycle
  • 48. Ngee Ann Polytechnic 48 PwmOut The default period is 0.020s, pulse width is 0
  • 49. PwmOut  LED1 LED4 PwmOut   Ngee Ann Polytechnic 49
  • 50. PwmOut Ngee Ann Polytechnic 50 #include "mbed.h" PwmOut led1(LED1); PwmOut led2(LED2); PwmOut led3(LED3); PwmOut led4(LED4); int main() { while (1) { for (float f = 0.0; f < 1.0; f += 0.001) { led1 = f; led2 = f * f; led3 = (f + 1.0) / 2.0; led4 = 1.0 - f; wait(0.01); } } } Take note that • All LEDs are assigned values from 0.0 to 1.0 • The brightness of the LEDs color changed abruptly
  • 51. PwmOut Ngee Ann Polytechnic 51 #include "mbed.h" #include <math.h> #ifndef M_PI #define M_PI 3.1415 #endif PwmOut led1(LED1); PwmOut led2(LED2); PwmOut led3(LED3); PwmOut led4(LED4); int main() { float f = 0.0; while (1) { Take note that • Using 4 sinusoidal waveforms, spaced 90o apart, the brightness of the LEDs varies smoothly • M_PI is a constant in <math.h> which is not defined in the C library from mbed.org • All sinusoidal values are computed dynamically only when it is needed. It is a bit CPU intensive // Add 1.0 to ensure all values are positive led1 = sin( (f ) * M_PI / 180.0) + 1.0; led2 = sin( (f + 90.0) * M_PI / 180.0) + 1.0; led3 = sin( (f + 180.0) * M_PI / 180.0) + 1.0; led4 = sin( (f + 270.0) * M_PI / 180.0) + 1.0; f += 1.0; wait(0.01); } }
  • 52. PwmOut Ngee Ann Polytechnic 52 #include "mbed.h" #include <math.h> #ifndef M_PI #define M_PI 3.1415 #endif #define STP 256 /* Step */ #define LED 4 /* Number of LEDs int main() { PwmOut Leds[] = {(LED1), (LED2), (LED3), (LED4)}; float y[STP][LED]; // Store all values float res = 360 / STP; // Resolution (degree per step) float x = 0.0; // Current x float ph = 360 / LED; // Phase different btw two successive LEDs for (int i = 0; i < STP; i++) { for (int j = 0; j < LED; j++) { y[i][j] = sin( (x + ph * j) * M_PI / 180.0) + 1.0; } x += res; // increment x by each resolution }
  • 53. Ngee Ann Polytechnic 53 while (1) { for (int i = 0; i < STP; i++) { for (int j = 0; j < LED; j++) { Leds[j] = y[i][j]; } count++; wait(0.01); } } } PwmOut Take note that • The code above run significantly faster than pervious example but consume slightly more memory in flash and RAM
  • 54.  1. RX 2. TX 3. GND   Start Stop Ngee Ann Polytechnic 54 8-bit Data Byte Parity Stop Start Optional
  • 55.   Ngee Ann Polytechnic 55 Space Space Mark Time Voltage +25V +3V -3V -25V Logic '0' Logic '1' Transition Region
  • 56.  Vcc  Ngee Ann Polytechnic 56 Space Space Mark Time Voltage Vcc V1H V0L Logic '0' Logic '1' Transition Region 0
  • 57. Ngee Ann Polytechnic 57 +5 V +15 V -15 V t t 1 0 0 1 1 1 1 10 0 0 0 Idle Start B0 B1 B3 B6 Stop IdleB2 B4 B5 B7 Transmission of the letter ‘J’ from μC to PC Logic value Meaning Signal level at the μC output pin (TX) Signal level at the PC input pin (RX) ASCII character ‘J’ is represented by • 0x4A or • 01001010 μC PC LevelShifter TX RX RX TX TX RX RX TX LSB MSB LSBMSB
  • 58. Serial Ngee Ann Polytechnic 58 mbed Device p9(TX) p10(RX) RX TX PC USB
  • 60. Ngee Ann Polytechnic 60 http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm
  • 62. Ngee Ann Polytechnic 62 If both devices are from the same power source, use CMOS Output. In this case, the input current to the microcontroller is actually taken from the +3V, and via the Source terminal of the MOSFET of the OUT pin of the Voltage Detector. If both devices are from different power sources, use Open Drain Output. In this case, the input current to the microcontroller is actually taken from +5V, and via the Drain terminal of the N- channel MOSFET of the OUT pin of the Voltage Detector. A resistor is necessary to reduce the amount of current drawn.