產品說明0
L298P Shield直流電機驅動器採用LGS公司優秀大功率電機專用驅動芯片L298P,可直接驅動2個直流電機,驅動電流達2A,電機輸出端採用8只高速肖特基二極管作為保護。疊層設計可直接插接到Arduino上,使用更加方便!
【模塊參數】:
※電機驅動電壓:外部輸入3-35V 內部輸入:6-12V
※邏輯端消電流:<30MA
※驅動電流:2A
※驅動峰值電流:4A
※最大功率:25W
※工作溫度:-25℃-130℃
可以直接插在ArduinoUNO、leonardo、mega2560等板上直接使用,不進行電流檢測的情況下,程序佔用主板四個引腳:
- PWMA:D4(~)引腳
- DIRA:D5引腳
- PWMB:D6(~)引腳
- DIRB:D7引腳
邏輯控制真值表如下:
【Arduino UNO 參考代碼如下】:
int E1 = 4; //PWMA
int M1 = 5; //DIRA
int E2 = 6; //PWMB
int M2 = 7; //DIRB
int Val = 0;
int ChangeValue = 20; //the speed value ,changevalue from 0-255
void setup()
{
pinMode(M1, OUTPUT);
pinMode(M2, OUTPUT);
}
void foward()
{
digitalWrite(M1,LOW);
analogWrite(E1, Val); //the speed value of motorA is 20
digitalWrite(M2,LOW);
analogWrite(E2, Val); //the speed value of motorB is 20
Val = Val + ChangeValue;
if (Val == 0 || Val == 255)
{
ChangeValue = -ChangeValue;
}
delay(100);
}
void back()
{
digitalWrite(M1,HIGH);
analogWrite(E1, Val); //PWM調速
digitalWrite(M2,HIGH);
analogWrite(E2, Val); //PWM調速
Val = Val + ChangeValue;
if (Val == 0 || Val == 255)
{
ChangeValue = -ChangeValue;
}
delay(100);
}
void loop()
{
foward();
delay(500);
back();
delay(500);
}