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:395831e5d094, 2018-12-14 (annotated)
- Committer:
- isshikiyuya
- Date:
- Fri Dec 14 06:22:54 2018 +0000
- Revision:
- 1:395831e5d094
- Parent:
- 0:53668fb4591a
- Child:
- 2:2d54c60eef4c
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
isshikiyuya | 1:395831e5d094 | 1 | #include "mbed.h" |
isshikiyuya | 0:53668fb4591a | 2 | |
isshikiyuya | 0:53668fb4591a | 3 | InterruptIn button1(A1); //フォトインタラプタ |
isshikiyuya | 0:53668fb4591a | 4 | InterruptIn button2(A2); //フォトインタラプタ |
isshikiyuya | 0:53668fb4591a | 5 | |
isshikiyuya | 1:395831e5d094 | 6 | |
isshikiyuya | 1:395831e5d094 | 7 | int count1 = 0; |
isshikiyuya | 1:395831e5d094 | 8 | int count2 = 0; |
isshikiyuya | 1:395831e5d094 | 9 | |
isshikiyuya | 0:53668fb4591a | 10 | PwmOut dout1(D1); |
isshikiyuya | 0:53668fb4591a | 11 | PwmOut dout5(D5); |
isshikiyuya | 0:53668fb4591a | 12 | PwmOut dout6(D6); |
isshikiyuya | 0:53668fb4591a | 13 | PwmOut dout9(D9); |
isshikiyuya | 0:53668fb4591a | 14 | |
isshikiyuya | 1:395831e5d094 | 15 | void flip1() { |
isshikiyuya | 1:395831e5d094 | 16 | count1++; |
isshikiyuya | 1:395831e5d094 | 17 | } |
isshikiyuya | 1:395831e5d094 | 18 | |
isshikiyuya | 1:395831e5d094 | 19 | void flip2() { |
isshikiyuya | 1:395831e5d094 | 20 | count2++; |
isshikiyuya | 1:395831e5d094 | 21 | } |
isshikiyuya | 1:395831e5d094 | 22 | |
isshikiyuya | 1:395831e5d094 | 23 | |
isshikiyuya | 0:53668fb4591a | 24 | int main() { |
isshikiyuya | 0:53668fb4591a | 25 | dout1.period(0.01f); //100Hz |
isshikiyuya | 0:53668fb4591a | 26 | dout5.period(0.01f); //100Hz |
isshikiyuya | 0:53668fb4591a | 27 | dout6.period(0.01f); //100Hz |
isshikiyuya | 0:53668fb4591a | 28 | dout9.period(0.01f); //100Hz |
isshikiyuya | 0:53668fb4591a | 29 | |
isshikiyuya | 1:395831e5d094 | 30 | |
isshikiyuya | 1:395831e5d094 | 31 | |
isshikiyuya | 1:395831e5d094 | 32 | button1.rise(&flip1); |
isshikiyuya | 1:395831e5d094 | 33 | button2.rise(&flip2); |
isshikiyuya | 1:395831e5d094 | 34 | |
isshikiyuya | 0:53668fb4591a | 35 | while(1) { |
isshikiyuya | 0:53668fb4591a | 36 | |
isshikiyuya | 0:53668fb4591a | 37 | dout1.write(0.5f); //50% duty |
isshikiyuya | 0:53668fb4591a | 38 | dout5.write(0.4f); //50% duty |
isshikiyuya | 0:53668fb4591a | 39 | dout6.write(0.2f); //50% duty |
isshikiyuya | 0:53668fb4591a | 40 | dout9.write(0.6f); //50% duty |
isshikiyuya | 0:53668fb4591a | 41 | |
isshikiyuya | 0:53668fb4591a | 42 | printf("%d\n",count1); |
isshikiyuya | 0:53668fb4591a | 43 | printf("%d\n\n",count2); |
isshikiyuya | 0:53668fb4591a | 44 | count1 = 0; |
isshikiyuya | 0:53668fb4591a | 45 | count2 = 0; |
isshikiyuya | 0:53668fb4591a | 46 | wait(1); |
isshikiyuya | 0:53668fb4591a | 47 | } |
isshikiyuya | 0:53668fb4591a | 48 | } |