Skip to content

Commit

Permalink
Final code flips
Browse files Browse the repository at this point in the history
  • Loading branch information
divs-2018 committed Nov 29, 2023
1 parent a66b963 commit ead4999
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/sender/sender.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Arduino Wireless Communication Tutorial
* Example 1 - Transmitter Code
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
Expand Down Expand Up @@ -54,17 +63,17 @@ void loop() {
}

if (abs(pwmOutputX-60) <= 40 && pwmOutputY<70) {
//Right
//Left
currentDir = 0;
buffer[0] = currentDir;
buffer[1] = changeSpeed(75);
Serial.println("Right");
buffer[1] = changeSpeed(105);
Serial.println("Left");
} else if (abs(pwmOutputX-60) <= 40 && pwmOutputY>110) {
//Left
//Right
currentDir = 120;
buffer[0] = currentDir;
buffer[1] = changeSpeed(75);
Serial.println("Left");
buffer[1] = changeSpeed(105);
Serial.println("Right");
} else if (pwmOutputX > 80 && abs(pwmOutputY-90) <= 40) {
//Backward
currentDir = 60;
Expand All @@ -83,6 +92,7 @@ void loop() {
buffer[0] = currentDir;
buffer[1] = changeSpeed(75);
Serial.println("backward right");

} else if (pwmOutputX < 40 && pwmOutputY < 70) {
//forward left
currentDir = 30;
Expand All @@ -101,6 +111,7 @@ void loop() {
buffer[0] = currentDir;
buffer[1] = changeSpeed(105);
Serial.println("forward right");

}
else {
// No movement
Expand All @@ -112,6 +123,7 @@ void loop() {
buffer[1] = changeSpeed(90);
//Serial.print("No movement:");
//Serial.println(currentSpeed);

}

radio.write(&buffer, sizeof(buffer));
Expand Down

0 comments on commit ead4999

Please sign in to comment.