A

Committer:
maenoshin
Date:
Wed Oct 30 03:29:47 2019 +0000
Revision:
0:286c3109789f
A

Who changed what in which revision?

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