|
請問如果說L298N的模組在執行程式時兩邊的輸出指示燈有亮但馬達會發出聲音沒動作ENA和ENB接上5V,用電表量測接上馬達時的電壓大概0.5~1V左右拔掉馬達後測量大約4~5v這樣是代表我的L298N掛了嗎??剛買回來時有成功運作幾次不過隔天在用別的程式去跑第一次還有動作之後就沒動作了而現在用測試程式去跑也完全沒反應指示燈一樣有亮不過馬達卻發出像氣球洩氣一般的聲音
L298N模組是用9V電池
ARDUINO UNO R3板子是用電腦的USB供電
L298N的GND有接到ARDUINO的GND
以下是我用來測試的程式
/* Input for motorA:
IN1 IN2 Action
LOW LOW Motor Stop
HIGH LOW Motor moves forward
LOW HIGH Motor moves backward
HIGH HIGH Motor Stop
*/
const int motorIn1 = 3;
const int motorIn2 = 4;
const int motorIn3 = 5;
const int motorIn4 = 6;
const int DELAY = 1000;
void setup()
{
pinMode(motorIn1, OUTPUT);
pinMode(motorIn2, OUTPUT);
pinMode(motorIn3, OUTPUT);
pinMode(motorIn4, OUTPUT);
}
void loop()
{
selfTest();
}
void selfTest()
{
forward();
delay(DELAY);
motorstop(); delay(500);
backward();
delay(DELAY);
motorstop(); delay(500);
right();
delay(DELAY);
motorstop(); delay(500);
left();
delay(DELAY);
motorstop(); delay(500);
}
void motorstop()
{
digitalWrite(motorIn1, LOW);
digitalWrite(motorIn2, LOW);
digitalWrite(motorIn3, LOW);
digitalWrite(motorIn4, LOW);
}
void forward()
{
digitalWrite(motorIn1, HIGH);
digitalWrite(motorIn2, LOW);
digitalWrite(motorIn3, HIGH);
digitalWrite(motorIn4, LOW);
}
void backward()
{
digitalWrite(motorIn1, LOW);
digitalWrite(motorIn2, HIGH);
digitalWrite(motorIn3, LOW);
digitalWrite(motorIn4, HIGH);
}
// Let right motor keep running, but stop left motor
void right()
{
digitalWrite(motorIn1, HIGH);
digitalWrite(motorIn2, LOW);
digitalWrite(motorIn3, LOW);
digitalWrite(motorIn4, LOW);
}
// Let left motor keep running, but stop right motor
void left()
{
digitalWrite(motorIn1, LOW);
digitalWrite(motorIn2, LOW);
digitalWrite(motorIn3, HIGH);
digitalWrite(motorIn4, LOW);
}
|
-
這是我所用的L298N
|