Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
satsob
/
Robotite_ylesannete_projekt
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9da7779b
authored
Oct 06, 2020
by
Oskar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update nRF_RobotControl.ino
parent
2f0a6a47
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
nRF_BTLE_ReceiveData/nRF_RobotControl/nRF_RobotControl.ino
nRF_BTLE_ReceiveData/nRF_RobotControl/nRF_RobotControl.ino
View file @
9da7779b
...
@@ -14,12 +14,12 @@
...
@@ -14,12 +14,12 @@
Servo
rightWheel
;
Servo
rightWheel
;
Servo
leftWheel
;
Servo
leftWheel
;
RF24
radio
(
9
,
10
);
// Create RF24 object to work with the RF24 library.
RF24
radio
(
9
,
10
);
// Create RF24 object to work with the RF24 library.
BTLE
btle
(
&
radio
);
// Create BTLE object to work with the BTLE library.
BTLE
btle
(
&
radio
);
// Create BTLE object to work with the BTLE library.
/* Replace! "CustomName" to the name of your device. Password - maximum length (14)! characters.
/* Replace! "CustomName" to the name of your device. Password - maximum length (14)! characters.
It's for recognizing the correct data packets. */
It's for recognizing the correct data packets. */
#define PASSWORD "
Galaxy A70
"
#define PASSWORD "
FBI van
"
/* Define functions used for the robot to control */
/* Define functions used for the robot to control */
/* Stop the robot */
/* Stop the robot */
...
@@ -28,24 +28,24 @@ void setWheelsStop() {
...
@@ -28,24 +28,24 @@ void setWheelsStop() {
leftWheel
.
writeMicroseconds
(
1500
);
leftWheel
.
writeMicroseconds
(
1500
);
}
}
/* Drive forward */
/* Drive forward */
void
setWheelsForward
(){
void
setWheelsForward
()
{
rightWheel
.
write
(
1300
);
rightWheel
.
write
Microseconds
(
1300
);
leftWheel
.
write
(
1700
);
leftWheel
.
write
Microseconds
(
1700
);
}
}
/* Drive right */
/* Drive right */
void
setWheelsRight
(){
void
setWheelsRight
()
{
rightWheel
.
write
(
1700
);
rightWheel
.
write
Microseconds
(
1700
);
leftWheel
.
write
(
1700
);
leftWheel
.
write
Microseconds
(
1700
);
}
}
/* Drive left */
/* Drive left */
void
setWheelsLeft
(){
void
setWheelsLeft
()
{
rightWheel
.
write
(
1300
);
rightWheel
.
write
Microseconds
(
1300
);
leftWheel
.
write
(
1300
);
leftWheel
.
write
Microseconds
(
1300
);
}
}
/* Drive backward */
/* Drive backward */
void
setWheelsBackward
(){
void
setWheelsBackward
()
{
rightWheel
.
write
(
1700
);
rightWheel
.
write
Microseconds
(
1700
);
leftWheel
.
write
(
1300
);
leftWheel
.
write
Microseconds
(
1300
);
}
}
void
setup
()
{
void
setup
()
{
...
@@ -70,9 +70,9 @@ void loop() {
...
@@ -70,9 +70,9 @@ void loop() {
if
(
btle
.
listen
())
{
if
(
btle
.
listen
())
{
// Serial.print("Got payload: "); // If data is received, print "Got payload: "
// Serial.print("Got payload: "); // If data is received, print "Got payload: "
/* Store the received data into the buffer */
/* Store the received data into the buffer */
for
(
uint8_t
i
=
2
;
i
<
(
btle
.
buffer
.
pl_size
)
-
6
;
i
++
)
{
for
(
uint8_t
i
=
2
;
i
<
(
btle
.
buffer
.
pl_size
)
-
6
;
i
++
)
{
str
+=
(
char
(
btle
.
buffer
.
payload
[
i
]));
str
+=
(
char
(
btle
.
buffer
.
payload
[
i
]));
// Serial.print(btle.buffer.payload[i],HEX); Serial.print(" ");
// To receive data in HEX format
// Serial.print(btle.buffer.payload[i], HEX); Serial.print(" ");
// To receive data in HEX format
// Serial.print(char (btle.buffer.payload[i])); Serial.print(" "); // To receive data in char format
// Serial.print(char (btle.buffer.payload[i])); Serial.print(" "); // To receive data in char format
}
}
...
@@ -101,12 +101,12 @@ void loop() {
...
@@ -101,12 +101,12 @@ void loop() {
setWheelsForward
();
setWheelsForward
();
delay
(
100
);
delay
(
100
);
}
}
}
}
else
{
else
{
Serial
.
println
(
"STOP"
);
Serial
.
println
(
"STOP"
);
setWheelsStop
();
setWheelsStop
();
delay
(
100
);
delay
(
100
);
}
}
}
}
/* Hop channels through 37-39 to scan for data transmissions */
/* Hop channels through 37-39 to scan for data transmissions */
...
...
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