-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmartCar.ino
62 lines (50 loc) · 1.23 KB
/
SmartCar.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!
#include <AFMotor.h>
AF_DCMotor motorFreEsq(1);
AF_DCMotor motorTrasEsq(2);
AF_DCMotor motorFreDir(3);
AF_DCMotor motorTrasDir(4);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
// turn on motor
motorFreEsq.setSpeed(200);
motorFreDir.setSpeed(200);
motorTrasEsq.setSpeed(200);
motorTrasDir.setSpeed(200);
para();
}
void loop() {
}
void frente() {
motorFreEsq.run(FORWARD);
motorFreDir.run(FORWARD);
motorTrasEsq.run(FORWARD);
motorTrasDir.run(FORWARD);
}
void tras() {
motorFreEsq.run(BACKWARD);
motorFreDir.run(BACKWARD);
motorTrasEsq.run(BACKWARD);
motorTrasDir.run(BACKWARD);
}
void esq() {
motorFreEsq.run(BACKWARD);
motorFreDir.run(FORWARD);
motorTrasEsq.run(BACKWARD);
motorTrasDir.run(FORWARD);
}
void dir() {
motorFreEsq.run(FORWARD);
motorFreDir.run(BACKWARD);
motorTrasEsq.run(FORWARD);
motorTrasDir.run(BACKWARD);
}
void para() {
motorFreEsq.run(RELEASE);
motorFreDir.run(RELEASE);
motorTrasEsq.run(RELEASE);
motorTrasDir.run(RELEASE);
}