Maenoshin Takahashi
/
1030_03
(Maenoshin)
main.cpp@0:2b95aa7efcd8, 2019-10-30 (annotated)
- Committer:
- maenoshin
- Date:
- Wed Oct 30 03:33:34 2019 +0000
- Revision:
- 0:2b95aa7efcd8
Kannushi ni simasita
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maenoshin | 0:2b95aa7efcd8 | 1 | #include "mbed.h" |
maenoshin | 0:2b95aa7efcd8 | 2 | |
maenoshin | 0:2b95aa7efcd8 | 3 | PwmOut AIN1(A1); |
maenoshin | 0:2b95aa7efcd8 | 4 | PwmOut AIN2(A2); |
maenoshin | 0:2b95aa7efcd8 | 5 | void go_forword (float duty){ |
maenoshin | 0:2b95aa7efcd8 | 6 | AIN1.write(0); |
maenoshin | 0:2b95aa7efcd8 | 7 | AIN2.write(duty); |
maenoshin | 0:2b95aa7efcd8 | 8 | } |
maenoshin | 0:2b95aa7efcd8 | 9 | void go_back (float duty){ |
maenoshin | 0:2b95aa7efcd8 | 10 | AIN1.write(duty); |
maenoshin | 0:2b95aa7efcd8 | 11 | AIN2.write(0); |
maenoshin | 0:2b95aa7efcd8 | 12 | } |
maenoshin | 0:2b95aa7efcd8 | 13 | |
maenoshin | 0:2b95aa7efcd8 | 14 | //DigitalOut out(D10);//D10ピンへの出力をコントロール |
maenoshin | 0:2b95aa7efcd8 | 15 | //digitalOut→0or1(ONorOFF)をコントロール、 |
maenoshin | 0:2b95aa7efcd8 | 16 | //myledはDigitalOut型の変数LED1のポートを初期化するという意味 |
maenoshin | 0:2b95aa7efcd8 | 17 | |
maenoshin | 0:2b95aa7efcd8 | 18 | //AnalogIn photo(A0); |
maenoshin | 0:2b95aa7efcd8 | 19 | //AnalogIn schmitt(A5); |
maenoshin | 0:2b95aa7efcd8 | 20 | |
maenoshin | 0:2b95aa7efcd8 | 21 | //void motor_control(PwmOut |
maenoshin | 0:2b95aa7efcd8 | 22 | |
maenoshin | 0:2b95aa7efcd8 | 23 | int main() { |
maenoshin | 0:2b95aa7efcd8 | 24 | float d=0.5; |
maenoshin | 0:2b95aa7efcd8 | 25 | |
maenoshin | 0:2b95aa7efcd8 | 26 | while(1) {//組み込み型のプログラムは無限ループになるようにする。(終わってはいけない) |
maenoshin | 0:2b95aa7efcd8 | 27 | |
maenoshin | 0:2b95aa7efcd8 | 28 | //正回転 |
maenoshin | 0:2b95aa7efcd8 | 29 | go_forword (d); |
maenoshin | 0:2b95aa7efcd8 | 30 | wait(5.0); // 1 sec |
maenoshin | 0:2b95aa7efcd8 | 31 | //逆回転 |
maenoshin | 0:2b95aa7efcd8 | 32 | go_back (d); |
maenoshin | 0:2b95aa7efcd8 | 33 | wait(5.0); // 1 sec |
maenoshin | 0:2b95aa7efcd8 | 34 | |
maenoshin | 0:2b95aa7efcd8 | 35 | if(d == 1.0)break; |
maenoshin | 0:2b95aa7efcd8 | 36 | d = d + 0.1; |
maenoshin | 0:2b95aa7efcd8 | 37 | |
maenoshin | 0:2b95aa7efcd8 | 38 | } |
maenoshin | 0:2b95aa7efcd8 | 39 | } |
maenoshin | 0:2b95aa7efcd8 | 40 | |
maenoshin | 0:2b95aa7efcd8 | 41 |