This page has a list of some of the different components of our mbed boards, and how to use those components.

LED lights

The two LED lights on Happy and Giant gecho are available on pin LED1 and LED2 (named LED0 on the board).

Library:

Works without any library (apart from mbed)

Init:

DigitalOut myled(LED1);

Turn on:

myled = 1;

Turn off:

myled = 0;

Example:

#include "mbed.h"

DigitalOut myled(LED1);

int main(){
    while(1){
        myled = 1;
        wait(0.5);
        myled = 0;
        wait(0.5);        
    }

}

Buttons

Both Happy and Giant Gecko have two physical push-buttons labeled "PB0" and "PB1". These are called "SW0" and "SW1" when programming with mbed. NB: PB0 og PB1 exists in mbed, but it is something else. Take care to use SW1/SW0 for for buttons

Library:

Works without any libraries (other than mbed)

Init: DigitalIn myButton0(SW1); DigitalIn myButton1(SW1);

Check if the button is pressed:

if(myButton0 == 0){

}

NB: myButton0 will be 0 when it is pressed and 1 when it is not pressed.

Checking if the button is not pressed:

if(myButton0 == 1){

}

Example:

#include "mbed.h"

DigitalOut myLed1(LED1);
DigitalOut myLed0(LED2);
DigitalIn myButton0(SW0);
DigitalIn myButton1(SW1);

int main() {
    while(1) {
        if(!myButton0){
            myLed0 = 1;
        }else{
            myLed0 = 0;
        }

        if(!myButton1){
            myLed1 = 1;
        }else{
            myLed1 = 0;
        }

        //Shorter version that does the same:
        // myLed0 = !myButton0;
        // myLed1 = !myButton1;
    }
}

Light measurement (Giant Gecko)

Slider (Giant Gecko)

LC-Sense

LCD Segment Display (only Giant Gecko)

Library:

EFM32_SegmentLCD

Include:

#include "EFM32_SegmentLCD.h"

Setup:

silabs::EFM32_SegmentLCD segmentDisplay;

Display text: segmentDisplay.Write("Hello");

If you have problems, try adding a 'wait(0.01f);' before the first Write-call.

For more functions, check out the API documentation.

Memory-LCD Display (only Happy Gecko)

More info to come at a later date, but if you want give it a try, check out this example:

MemoryLCD

Temperature and humidity sensor (only Happy Gecko)

Silicon Labs Si7021 https://developer.mbed.org/teams/SiliconLabs/code/SILABS_RHT/