Control H Bidge Gear Motor Control [P003]
https://www.youtube.com/watch?v=BvaAhAsRyBo
*GitHub : https://github.com/rdiot/rdiot-p003.git
* Parts
- Arduino Uno R3
- L298N Dual Motor Driver H Bridge (L298N) [B005]
- TT Motor Car Gear Motor [S142]
* Contents
- Connect
ENA ----- D9
IN1 ----- D2
IN2 ----- D3
ENB ----- D10
IN3 ----- D4
IN4 ----- D5
- Key Code
int dir1PinA = 2;
int dir2PinA = 3;
int dir1PinB = 4;
int dir2PinB = 5;
int speedPinA = 9;
int speedPinB = 10;
int speed1;
int dir;
void setup()
{
pinMode(dir1PinA,OUTPUT); // IN1
pinMode(dir2PinA,OUTPUT); // IN2
pinMode(speedPinA,OUTPUT); // ENA
pinMode(dir1PinB,OUTPUT); // IN3
pinMode(dir2PinB,OUTPUT); // IN4
pinMode(speedPinB,OUTPUT); // ENB
speed1 = 200;
dir = 1;
delay(1000);
}
void loop()
{
//analogWrite(speedPinA, speed1); // 200 -> ENA
if(dir == 1)
{
digitalWrite(speedPinA, HIGH);
digitalWrite(speedPinB, HIGH);
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, HIGH);
digitalWrite(dir1PinB, LOW);
digitalWrite(dir2PinB, HIGH);
delay(5000);
digitalWrite(speedPinA, HIGH);
digitalWrite(speedPinB, HIGH);
digitalWrite(dir1PinA, HIGH);
digitalWrite(dir2PinA, LOW);
digitalWrite(dir1PinB, HIGH);
digitalWrite(dir2PinB, LOW);
delay(5000);
}
}
'3) Actuator > Motor_Driver' 카테고리의 다른 글
L9110S 2-Channel Dual Motor Driver (L9110S) [B042] (0) | 2016.10.05 |
---|---|
ULN2003 Stepper Motor driver (X113647) [B002] (0) | 2016.10.05 |
L298N Dual Motor Driver H Bridge (L298N) [B005] (0) | 2016.10.05 |
6~28V 3A Motor Speed Controller [B056] (0) | 2016.10.05 |