motor driver L298P smars robot connecting to Arduino Uno board
Control of two DC motors connections:
/*
L298P-Motor-Driver-Shield
made on 09 Nov 2020
by Amir Mohammad Shojaee @ Electropeak
Home
*/
int pwmA = 10; //pwm motor A
int pwmB = 11;
int enA = 12; //logic motor A
int enB = 13;
int buz = 4;
void setup() {
pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(buz, OUTPUT);
}
void loop() {
for (int x = 50; x < 200; x++) {
digitalWrite(enA, HIGH);
digitalWrite(enB, HIGH);
analogWrite(pwmA, x);
analogWrite(pwmB, x);
delay(10);
}
for (int y = 200; y > 50; y--) {
digitalWrite(enA, HIGH);
digitalWrite(enB, HIGH);
digitalWrite(buz, HIGH);
analogWrite(pwmA, y);
analogWrite(pwmB, y);
delay(1);
}
digitalWrite(buz, LOW);
delay(1000);
}
VMS: Module voltage
GND: Ground
MA1: Positive end for motor A
MA2: Negative end for motor A
MB1: Positive end for motor B
MB2: Negative end for motor B
PWMA: Speed control signal for motor A – This pin is connected to pin 10 of Arduino
PWMB: Speed control signal for motor B – This pin is connected to pin 11 of Arduino
ENA: Control signal for motor A – If HIGH, motor is in direct mode and if LOW, motor is rotating in reverse. This pin is connected to pin 12 of Arduino
ENB: Control signal for motor B – If HIGH, motor is in direct mode and if LOW, motor is rotating in reverse. This pin is connected to pin 13 of Arduino
Buzzer for make sound:
BUZ: Buzzer pin – This pin is connected to pin 4 of Arduino
Connection for control servo motor:
SER: PWM pin for control servo motor – This pin is connected to pin 9 of Arduino
Bluetooth connections:
BT2: Bluetooth Pins including +(3.3V) pins, (GND), RX (connected to D0) and TX (connected to D1)
Ultrasonic sensor connection:
ULT: connection pins to ultrasonic sensor including +(5V), (GND), Return (connected to D9) and Trigger (connected to D8)
RBG LED connection:
RGB: RGB: For connection to RGB LED including pins B (connected to D6), G (connected to D5) and R (connected to D3)
Other connections:
A/D: Analog and digital pins A0 to A5 for sensor and module use
D2: Digital pin 2 for sensor and module use
RS: Reset pin
GND: Ground
VCC: Board power supply – 3V, 5V
You can see the pinout of this module in the image below.
also read https://cendikialearning.blogspot.com/2022/01/bridge-mengabungkan-port-menjadi-1.html



Tidak ada komentar:
Posting Komentar