トランジスタ技術2015年6月号mbedラジコン・カーp184 リスト4 Bluetoothモジュールのmbedメイン・プログラム

Dependencies:   mbed

main.cpp

Committer:
YoshihitoShimada
Date:
2015-06-01
Revision:
0:e423d98fecae

File content as of revision 0:e423d98fecae:

#include "mbed.h"
Serial bluetooth(P0_19, P0_18); //tx, rx
DigitalOut Light(P0_16);

int main() {
    bluetooth.baud(115200);
    int32_t i;
    uint8_t buf;
    char moji[64];

    Light=0;

    while (1) {
        if(bluetooth.readable()) {
            i=0;
            do {
                buf=bluetooth.getc();
                moji[i++]=buf;
            } while(buf!='\0');
            buf=moji[0];
        }
        switch (buf){
        case '+':   //Light On
            Light=1;
            break;
        case '-':   //Light Off
            Light=0;
            break;
        }
    }
}