Here you can find the code and project files for the GPIO example, in this example the 3 colors of the RGB led are turned on sequentially when the SW2 push button is pressed, the led pin definition is shared throughout all the freedom platforms. The wait function can be defined in seconds, miliseconds or microseconds.
Code:
#include "mbed.h"
//Delay declared in seconds
/*GPIO declaration*/
DigitalOut Red(LED1);
DigitalOut Green(LED2);
DigitalOut Blue(LED3);
DigitalIn sw2(SW2);
int main()
{
/*Leds OFF*/
Red=1;
Green=1;
Blue=1;
while(1)
{
if(sw2==0)
{
Red = 0;
wait(.2);
Red = 1;
wait(1);
Green=0;
wait(.2);
Green=1;
wait(1);
Blue=0;
wait(.2);
Blue=1;
wait(1);
}
}
}