mbed FRDM KL25Z Examples

/media/uploads/chris/frd_small.jpg

mbed FRDM-KL25Z - Hello World!

Import program

00001 #include "mbed.h"
00002 
00003 int main() {
00004     DigitalOut gpo(PTB8);
00005     DigitalOut led(LED_RED);
00006 
00007     while (true) {
00008         gpo = 1;
00009         led = 1; // Off
00010         wait(2);
00011         gpo = 0;
00012         led = 0; // on
00013         wait(2);
00014     }
00015 }

Touch Sensor - Hello World!

Import program

00001 #include "mbed.h"
00002 #include "TSISensor.h"
00003 
00004 int main(void) {
00005     PwmOut led(LED_GREEN);
00006     TSISensor tsi;
00007     
00008     while (true) {
00009         led = 1.0 - tsi.readPercentage();
00010         wait(0.1);
00011     }
00012 }

Accelerometer Example - Hello World!

Import program

00001 #include "mbed.h"
00002 #include "MMA8451Q.h"
00003 
00004 #define MMA8451_I2C_ADDRESS (0x1d<<1)
00005 
00006 int main(void) {
00007     MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
00008     PwmOut rled(LED_RED);
00009     PwmOut gled(LED_GREEN);
00010     PwmOut bled(LED_BLUE);
00011 
00012     while (true) {
00013         rled = 1.0 - abs(acc.getAccX());
00014         gled = 1.0 - abs(acc.getAccY());
00015         bled = 1.0 - abs(acc.getAccZ());
00016         wait(0.1);
00017     }
00018 }

RGB LED - Hello World!

Import programFRDM_RGBLED

Example program driving the RGB LED by PWM, sweeping through the color space

Ticker - Hello World!

Import programFRDM_Ticker

Example program using a ticker to regularly flip and LED

Timeout - Hello World!

Import programFRDM_Timeout

Example program using the timeout to call a function after a fixed amount of time

Serial port - Hello World!

Before you can use the USB Serial port functionality, visit the Serial PC page for the USB serial drivers and terminal programs :

Import programFRDM_Serial

Example program using USB Serial port

Timer - Hello World!

Import programFRDM_Timer

Example program using a timer to determine how long it takes to execute a printf command

See also