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.
function.h@4:45b45e8ca173, 2018-12-17 (annotated)
- Committer:
- isshikiyuya
- Date:
- Mon Dec 17 05:55:01 2018 +0000
- Revision:
- 4:45b45e8ca173
- Child:
- 7:de699a50fc63
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
isshikiyuya | 4:45b45e8ca173 | 1 | #include "mbed.h" |
isshikiyuya | 4:45b45e8ca173 | 2 | |
isshikiyuya | 4:45b45e8ca173 | 3 | /////////////////////////////////////// |
isshikiyuya | 4:45b45e8ca173 | 4 | int led_count1 = 0;//led用のカウンタ |
isshikiyuya | 4:45b45e8ca173 | 5 | int led_count2 = 0;//led用のカウンタ |
isshikiyuya | 4:45b45e8ca173 | 6 | int count1 = 0;//フィードバック用のカウンタ |
isshikiyuya | 4:45b45e8ca173 | 7 | int count2 = 0;//フィードバック用のカウンタ |
isshikiyuya | 4:45b45e8ca173 | 8 | int distance1 = 0;//右タイヤ |
isshikiyuya | 4:45b45e8ca173 | 9 | int distance2 = 0;//左タイヤ |
isshikiyuya | 4:45b45e8ca173 | 10 | int distance = 0;//平均 |
isshikiyuya | 4:45b45e8ca173 | 11 | int c = 0;// 1秒ごとの回転数 |
isshikiyuya | 4:45b45e8ca173 | 12 | int c1 = 0;//右の回転数 |
isshikiyuya | 4:45b45e8ca173 | 13 | int c2 = 0;//左の回転数 |
isshikiyuya | 4:45b45e8ca173 | 14 | |
isshikiyuya | 4:45b45e8ca173 | 15 | |
isshikiyuya | 4:45b45e8ca173 | 16 | Ticker flipper; |
isshikiyuya | 4:45b45e8ca173 | 17 | |
isshikiyuya | 4:45b45e8ca173 | 18 | void flip1() { |
isshikiyuya | 4:45b45e8ca173 | 19 | led_count1++; |
isshikiyuya | 4:45b45e8ca173 | 20 | count1++; |
isshikiyuya | 4:45b45e8ca173 | 21 | distance1++; |
isshikiyuya | 4:45b45e8ca173 | 22 | } |
isshikiyuya | 4:45b45e8ca173 | 23 | |
isshikiyuya | 4:45b45e8ca173 | 24 | void flip2() { |
isshikiyuya | 4:45b45e8ca173 | 25 | led_count2++; |
isshikiyuya | 4:45b45e8ca173 | 26 | count2++; |
isshikiyuya | 4:45b45e8ca173 | 27 | distance2++; |
isshikiyuya | 4:45b45e8ca173 | 28 | } |
isshikiyuya | 4:45b45e8ca173 | 29 | |
isshikiyuya | 4:45b45e8ca173 | 30 | void flip3(){ |
isshikiyuya | 4:45b45e8ca173 | 31 | c = 20*( count1 + count2 ) / 2;//cは1秒ごとのパルス数 |
isshikiyuya | 4:45b45e8ca173 | 32 | c1 = 20*count1; |
isshikiyuya | 4:45b45e8ca173 | 33 | c2 = 20*count2; |
isshikiyuya | 4:45b45e8ca173 | 34 | |
isshikiyuya | 4:45b45e8ca173 | 35 | count1 = 0; |
isshikiyuya | 4:45b45e8ca173 | 36 | count2 = 0; |
isshikiyuya | 4:45b45e8ca173 | 37 | } |
isshikiyuya | 4:45b45e8ca173 | 38 | |
isshikiyuya | 4:45b45e8ca173 | 39 | |
isshikiyuya | 4:45b45e8ca173 | 40 | /* |
isshikiyuya | 4:45b45e8ca173 | 41 | class Sample{ |
isshikiyuya | 4:45b45e8ca173 | 42 | private: |
isshikiyuya | 4:45b45e8ca173 | 43 | count; |
isshikiyuya | 4:45b45e8ca173 | 44 | public: |
isshikiyuya | 4:45b45e8ca173 | 45 | Sample(); |
isshikiyuya | 4:45b45e8ca173 | 46 | void counter(); |
isshikiyuya | 4:45b45e8ca173 | 47 | void counter2(int &num); |
isshikiyuya | 4:45b45e8ca173 | 48 | }; |
isshikiyuya | 4:45b45e8ca173 | 49 | |
isshikiyuya | 4:45b45e8ca173 | 50 | Sample::Sample() |
isshikiyuya | 4:45b45e8ca173 | 51 | { |
isshikiyuya | 4:45b45e8ca173 | 52 | count=0; |
isshikiyuya | 4:45b45e8ca173 | 53 | } |
isshikiyuya | 4:45b45e8ca173 | 54 | |
isshikiyuya | 4:45b45e8ca173 | 55 | void Sample::counter() |
isshikiyuya | 4:45b45e8ca173 | 56 | { |
isshikiyuya | 4:45b45e8ca173 | 57 | count++; |
isshikiyuya | 4:45b45e8ca173 | 58 | } |
isshikiyuya | 4:45b45e8ca173 | 59 | |
isshikiyuya | 4:45b45e8ca173 | 60 | void Sample::counter2(int& num) |
isshikiyuya | 4:45b45e8ca173 | 61 | { |
isshikiyuya | 4:45b45e8ca173 | 62 | num+=1; |
isshikiyuya | 4:45b45e8ca173 | 63 | } |
isshikiyuya | 4:45b45e8ca173 | 64 | |
isshikiyuya | 4:45b45e8ca173 | 65 | */ |