Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- knzw
- Date:
- 2019-09-15
- Revision:
- 0:48ce5ea63822
File content as of revision 0:48ce5ea63822:
/* mbed Microcontroller Library
* Copyright (c) 2018 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*/
/* ボタン押している間なにかする処理のサンプルプログラム的な(モーメンタリ動作というらしい) */
#include "mbed.h"
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
#define SLEEP_TIME 500 // (msec)
#define PRINT_AFTER_N_LOOPS 20
static InterruptIn btn0(USER_BUTTON0);
static bool btndownflg=false; //falseのとき、ボタンを離している
void btnfall0(void){
btndownflg=true;//ボタンおした
}
void btnrise0(void){
btndownflg=false;//ボタンはなれた
}
int main(){
btn0.fall(&btnfall0); //ボタンを押したときに関数btnfall0を呼び出す
btn0.rise(&btnrise0); //ボタンを離したときに関数をbtnrise0を呼び出す
while (true) {
if(btndownflg){
led1=true;
led2=true;
led3=true;
led4=true;
}else{
led1=false;
led2=false;
led3=false;
led4=false;
}
}
}