forked from ProfBoots/MiniSkidi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBT_TEMP.ino
124 lines (109 loc) · 2.45 KB
/
BT_TEMP.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <ESP32Servo.h>
#include <DabbleESP32.h>
#define INCLUDE_GAMEPAD_MODULE
int dirPin2 = 32;
int dirPin1 = 33;
int dirPin4 = 25;
int dirPin3 = 26;
int x = 90;
int y = 90;
Servo myservo;
Servo myservo2;
void setup() {
myservo.attach(5);
myservo.write(y);
myservo2.attach(18);
myservo2.write(x);
pinMode(dirPin1, OUTPUT);
pinMode(dirPin2, OUTPUT);
pinMode(dirPin3, OUTPUT);
pinMode(dirPin4, OUTPUT);
Serial.begin(250000); // Set your Serial Monitor is set at 250000
Dabble.begin("My Esp32"); // This is the baude rate of the HM-10
}
void loop() {
Dabble.processInput(); { // This line is crucial in grabbing our data
if (GamePad.isUpPressed())
{
Serial.println("Forward");
digitalWrite(dirPin1, HIGH);
digitalWrite(dirPin2, LOW);
digitalWrite(dirPin3, HIGH);
digitalWrite(dirPin4, LOW);
}
else if (GamePad.isDownPressed())
{
Serial.println("Backward");
digitalWrite(dirPin1, LOW);
digitalWrite(dirPin2, HIGH);
digitalWrite(dirPin3, LOW);
digitalWrite(dirPin4, HIGH);
}
else if (GamePad.isLeftPressed())
{
Serial.println("Left");
digitalWrite(dirPin3, LOW);
digitalWrite(dirPin4, HIGH);
digitalWrite(dirPin1, HIGH);
digitalWrite(dirPin2, LOW);
}
else if (GamePad.isRightPressed())
{
Serial.println("Right");
digitalWrite(dirPin3, HIGH);
digitalWrite(dirPin4, LOW);
digitalWrite(dirPin1, LOW);
digitalWrite(dirPin2, HIGH);
}
else if (GamePad.isStartPressed())
{
}
else if (GamePad.isSelectPressed())
{
}
else if (GamePad.isTrianglePressed())
{
if(x<170)
{
x++;
myservo2.write(x);
delay(10);
}
}
else if (GamePad.isCrossPressed())
{
if(x>10)
{
x--;
myservo2.write(x);
delay(10);
}
}
else if (GamePad.isSquarePressed())
{
if(y<170)
{
y++;
myservo.write(y);
delay(10);
}
}
else if (GamePad.isCirclePressed())
{
if(y>10)
{
y--;
myservo.write(y);
delay(10);
}
}
else
{
Serial.println("Stopped");
digitalWrite(dirPin1, LOW);
digitalWrite(dirPin2, LOW);
digitalWrite(dirPin3, LOW);
digitalWrite(dirPin4, LOW);
}
}
}