PWM に挑戦

mbed に付いているLEDの明るさを変化させる。

include the mbed library with this snippet

#include "mbed.h"

PwmOut led(LED1);

int main()
{
    while(1) {
        for(float p = 0.0f; p < 1.0f; p += 0.1f) {
            led = p;
            wait(0.1);
        }
    }
}


21ピンを使ってやってみる
/media/uploads/yamato/005.png

include the mbed library with this snippet

#include "mbed.h"

PwmOut led(p21);

int main()
{
    while(1) {
        for(float p = 0.0f; p < 1.0f; p += 0.1f) {
            led = p;
            wait(0.1);
        }
    }
}


Please log in to post comments.