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.
Dependencies: mbed
main.cpp@1:3af0f173b7fe, 2019-12-06 (annotated)
- Committer:
- komachiangel72
- Date:
- Fri Dec 06 05:12:03 2019 +0000
- Revision:
- 1:3af0f173b7fe
- Parent:
- 0:51578a4c3bf8
a
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| komachiangel72 | 0:51578a4c3bf8 | 1 | #include "mbed.h" |
| komachiangel72 | 0:51578a4c3bf8 | 2 | |
| komachiangel72 | 0:51578a4c3bf8 | 3 | //DigitalOut out(D10);//D10ピンへの出力をコントロール |
| komachiangel72 | 0:51578a4c3bf8 | 4 | //digitalOut→0or1(ONorOFF)をコントロール、 |
| komachiangel72 | 0:51578a4c3bf8 | 5 | //myledはDigitalOut型の変数LED1のポートを初期化するという意味 |
| komachiangel72 | 0:51578a4c3bf8 | 6 | |
| komachiangel72 | 0:51578a4c3bf8 | 7 | //AnalogIn photo(A0); |
| komachiangel72 | 0:51578a4c3bf8 | 8 | //AnalogIn schmitt(A5); |
| komachiangel72 | 0:51578a4c3bf8 | 9 | |
| komachiangel72 | 1:3af0f173b7fe | 10 | InterruptIn enc(D10); |
| komachiangel72 | 0:51578a4c3bf8 | 11 | DigitalOut led(LED1); |
| komachiangel72 | 0:51578a4c3bf8 | 12 | |
| komachiangel72 | 0:51578a4c3bf8 | 13 | int counter =0; |
| komachiangel72 | 0:51578a4c3bf8 | 14 | |
| komachiangel72 | 0:51578a4c3bf8 | 15 | void event_handler(void){ |
| komachiangel72 | 0:51578a4c3bf8 | 16 | counter++; |
| komachiangel72 | 0:51578a4c3bf8 | 17 | led =!led; |
| komachiangel72 | 0:51578a4c3bf8 | 18 | } |
| komachiangel72 | 0:51578a4c3bf8 | 19 | |
| komachiangel72 | 0:51578a4c3bf8 | 20 | int main() { |
| komachiangel72 | 0:51578a4c3bf8 | 21 | //out = 1; // 電流を流す |
| komachiangel72 | 0:51578a4c3bf8 | 22 | enc.rise(&event_handler); |
| komachiangel72 | 0:51578a4c3bf8 | 23 | enc.fall(&event_handler); |
| komachiangel72 | 0:51578a4c3bf8 | 24 | |
| komachiangel72 | 0:51578a4c3bf8 | 25 | int i = 0; |
| komachiangel72 | 0:51578a4c3bf8 | 26 | |
| komachiangel72 | 0:51578a4c3bf8 | 27 | while(1) {//組み込み型のプログラムは無限ループになるようにする。(終わってはいけない) |
| komachiangel72 | 0:51578a4c3bf8 | 28 | |
| komachiangel72 | 0:51578a4c3bf8 | 29 | //wait(1.0); // 1 sec |
| komachiangel72 | 0:51578a4c3bf8 | 30 | //printf("photo:L432[%.3f]>\n",photo.read()*3.3F);//電圧測定 |
| komachiangel72 | 0:51578a4c3bf8 | 31 | |
| komachiangel72 | 0:51578a4c3bf8 | 32 | //wait(1.0); |
| komachiangel72 | 0:51578a4c3bf8 | 33 | //printf("schmitt:L432[%.3f]>\n",schmitt.read()*3.3F);//電圧測定 |
| komachiangel72 | 0:51578a4c3bf8 | 34 | |
| komachiangel72 | 0:51578a4c3bf8 | 35 | printf("%d\n",counter); |
| komachiangel72 | 0:51578a4c3bf8 | 36 | |
| komachiangel72 | 0:51578a4c3bf8 | 37 | wait(1.0); |
| komachiangel72 | 0:51578a4c3bf8 | 38 | |
| komachiangel72 | 0:51578a4c3bf8 | 39 | i++; |
| komachiangel72 | 1:3af0f173b7fe | 40 | if (i == 100 )break; |
| komachiangel72 | 0:51578a4c3bf8 | 41 | |
| komachiangel72 | 0:51578a4c3bf8 | 42 | } |
| komachiangel72 | 0:51578a4c3bf8 | 43 | } |