FRDM-K64 GPIO basic example using mbed

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

FRDM-K64 GPIO basic example using mbed

FRDM-K64 GPIO basic example using mbed

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);

        }

    }

}

附件
评论

Hi Pedro, I can't seem to get this to work on my board. I think mbed has a problem with using SW2 and SW3 as I can't seem to get this working with any mbed project.

mmm seems weird, I tried the code with more than 10 different boards, you can try using the pin's name instead of using the SWn tag

For some reason it seemed to clear itself after I tried doing some stuff with interrupts!

hi. I'm new and I'm using Keil ARM complier. I can't open your files.
I get a problem with reading the state of button.
plz show me the description of DigitalIn sw2(SW2); function
thanks so much

I can turn on/off the RGB led, I tried to read the state of the push button but I can't
plz help me

无评分
版本历史
最后更新:
‎06-27-2014 10:31 AM
更新人: