Android+Arduino, その3
動き出しました.Ardumotoのサンプルスケッチを改変して,まずピン定義.int ch_R = 2; // audio channel Rint ch_L = 4; // audio channel Lsetup中に以下を記述. pinMode(ch_R, INPUT); // 右チャンネル入力設定 pinMode(ch_L, INPUT); // 左チャンネル入力設定 digitalWrite(dir_a, LOW); //Set motor direction, 1 low, 2 high digitalWrite(dir_b, LOW); //Set motor direction, 3 high, 4 low analogWrite(pwm_a, 0); analogWrite(pwm_b, 0); loop中に以下を記述.元のサンプルの記述は削除.パルス幅を測って,500μs以上か以下かでモータの方向を決めて回してます. pR=pulseIn(ch_R,HIGH,10000); pL=pulseIn(ch_L,HIGH,10000); if (pR !=0 ){ if (pR