Commit e1f559c0 by rosere

Upload New File

parent e3ebe88c
Showing with 51 additions and 0 deletions
/* Arduino DC Motor Control - PWM | H-Bridge | L298N
Example 02 - Arduino Robot Car Control
by Dejan Nedelkovski, www.HowToMechatronics.com
test tanki jaoks
*/
#define enA 6
#define in1 8
#define in2 9
#define enB 5
#define in3 3
#define in4 4
int motorSpeedA = 0;
int motorSpeedB = 0;
int i;
void setup() {
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
void loop() {
// Set Motor A forkward
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
// Set Motor B forward
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
for (i = 0; i < 255; i +=10)
{
analogWrite(enA, i); // Send PWM signal to motor A
analogWrite(enB, i); // Send PWM signal to motor B
delay(200);
}
delay(2000);
// Set Motor A backward
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
// Set Motor B backward
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
for (i = 0; i < 255; i +=10)
{
analogWrite(enA, i); //
analogWrite(enB, i);
delay(200);
}
delay(2000);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment