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
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2018 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 */ 00005 00006 /* ボタン押している間なにかする処理のサンプルプログラム的な(モーメンタリ動作というらしい) */ 00007 #include "mbed.h" 00008 00009 DigitalOut led1(LED1); 00010 DigitalOut led2(LED2); 00011 DigitalOut led3(LED3); 00012 DigitalOut led4(LED4); 00013 00014 #define SLEEP_TIME 500 // (msec) 00015 #define PRINT_AFTER_N_LOOPS 20 00016 00017 static InterruptIn btn0(USER_BUTTON0); 00018 static bool btndownflg=false; //falseのとき、ボタンを離している 00019 00020 void btnfall0(void){ 00021 btndownflg=true;//ボタンおした 00022 } 00023 00024 void btnrise0(void){ 00025 btndownflg=false;//ボタンはなれた 00026 } 00027 00028 00029 int main(){ 00030 00031 btn0.fall(&btnfall0); //ボタンを押したときに関数btnfall0を呼び出す 00032 btn0.rise(&btnrise0); //ボタンを離したときに関数をbtnrise0を呼び出す 00033 00034 while (true) { 00035 if(btndownflg){ 00036 led1=true; 00037 led2=true; 00038 led3=true; 00039 led4=true; 00040 }else{ 00041 led1=false; 00042 led2=false; 00043 led3=false; 00044 led4=false; 00045 } 00046 } 00047 }
Generated on Sat Jul 30 2022 00:28:00 by
1.7.2