Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
altabo
/
Tankipoisid
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e1f559c0
authored
Dec 02, 2019
by
rosere
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
e3ebe88c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
tank_0.1.ino
tank_0.1.ino
0 → 100644
View file @
e1f559c0
/* 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
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment