Compare commits
No commits in common. "master" and "Structs" have entirely different histories.
16
Links.md
16
Links.md
|
@ -1,16 +0,0 @@
|
|||
DroneBot Workshop: The nRF24L01 - Wireless Joystick for Arduino Robot Car with nRF24L01+
|
||||
|
||||
https://www.youtube.com/watch?v=lhGXAJj8rJw
|
||||
|
||||
Max Imagination: DIY RC Transmitter & Receiver/Controller | Arduino-based 7-CH Radio Controller NRF24L01
|
||||
|
||||
https://www.youtube.com/watch?v=47eBRwFQp-g
|
||||
|
||||
Andreas Spiess: Advanced Tutorial for NRF24L01 and Arduino #1
|
||||
|
||||
https://www.youtube.com/watch?v=61kWj6zu4Uw
|
||||
|
||||
Andreas Spiess: Advanced Tutorial for NRF24L01 and Arduino #2 Reliable Connections
|
||||
|
||||
https://www.youtube.com/watch?v=a2FBa4MK66M
|
||||
|
|
@ -1 +0,0 @@
|
|||

|
|
@ -1,6 +1,2 @@
|
|||
# Daten für das Radio_FahrzeugV2
|
||||
|
||||
## Todos
|
||||
~~Io pins beim external chip wechseln könnten sie nutzbar machen https://www.youtube.com/watch?v=lhGXAJj8rJw&t=10m10s~~
|
||||
Alle Bewegungen mit Mecanum-Rädern hinzufügen.
|
||||
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
//TODO Füge alle möglichen bewegungen hinzu
|
||||
//TODO Mache es möglich Motoren geschwindigkeit mit analog zu kontolieren
|
||||
RF24 radio(7, 8); // (CE, CSN)
|
||||
int pwmx;
|
||||
int pwmy;
|
||||
|
||||
const byte address[6] = "1RF24";
|
||||
struct dataStruct {
|
||||
int Xposition;
|
||||
|
@ -19,48 +18,29 @@ void setup() {
|
|||
Serial.begin(9600);
|
||||
radio.begin();
|
||||
radio.setPALevel(RF24_PA_MAX);
|
||||
radio.setChannel(50);
|
||||
radio.setChannel(125);
|
||||
radio.openReadingPipe(0, address);
|
||||
radio.startListening();
|
||||
pinMode(2, OUTPUT);
|
||||
pinMode(3, OUTPUT);
|
||||
pinMode(4, OUTPUT);
|
||||
pinMode(5, OUTPUT);
|
||||
pinMode(10, OUTPUT);
|
||||
pinMode(11, OUTPUT);
|
||||
pinMode(A2, OUTPUT);
|
||||
pinMode(A3, OUTPUT);
|
||||
pinMode(A4, OUTPUT);
|
||||
pinMode(A5, OUTPUT);
|
||||
|
||||
}
|
||||
int pwm(int x) {
|
||||
int out;
|
||||
if (x < 512) { //Check if joystick is above, below, or at the middle and calculate the unmapped output
|
||||
x = 512 - x;
|
||||
}
|
||||
if (x > 512) {
|
||||
x = x - 512;
|
||||
}
|
||||
if (x == 512) {
|
||||
x = 0;
|
||||
}
|
||||
out = map(x, 0, 1023, 100, 255); //Map the output to a PWM value
|
||||
Serial.println(x);
|
||||
return out; //Return the value
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (radio.available()) {
|
||||
radio.read( &myData, sizeof(myData) );
|
||||
//Serial.print("Y Pos");
|
||||
//Serial.println(myData.Yposition);
|
||||
//Serial.print("X Pos");
|
||||
//Serial.println(myData.Xposition);
|
||||
pwmx=pwm(myData.Xposition);
|
||||
pwmy=pwm(myData.Yposition);
|
||||
Serial.print("Y Pos");
|
||||
Serial.println(myData.Yposition);
|
||||
Serial.print("X Pos");
|
||||
Serial.println(myData.Xposition);
|
||||
if (myData.Yposition >= 700) {
|
||||
|
||||
digitalWrite(3, 1);
|
||||
digitalWrite(2, 0);
|
||||
digitalWrite(4, 0);
|
||||
|
@ -69,9 +49,6 @@ void loop() {
|
|||
digitalWrite(A2, 0);
|
||||
digitalWrite(A4, 0);
|
||||
digitalWrite(A5, 1);
|
||||
|
||||
analogWrite(10,pwmy);
|
||||
analogWrite(11,pwmy);
|
||||
}
|
||||
|
||||
if (myData.Yposition <= 200) {
|
||||
|
@ -83,9 +60,6 @@ void loop() {
|
|||
digitalWrite(A3, 0);
|
||||
digitalWrite(A5, 0);
|
||||
digitalWrite(A4, 1);
|
||||
//Serial.println(pwmy);
|
||||
//analogWrite(10,pwmy);
|
||||
//analogWrite(11,pwmy);
|
||||
}
|
||||
if (myData.Xposition >= 700){
|
||||
digitalWrite(3, 1);
|
||||
|
@ -96,8 +70,6 @@ void loop() {
|
|||
digitalWrite(A2, 0);
|
||||
digitalWrite(A4, 1);
|
||||
digitalWrite(A5, 0);
|
||||
analogWrite(10,pwmx);
|
||||
analogWrite(11,pwmx);
|
||||
}
|
||||
if (myData.Xposition <= 200){
|
||||
digitalWrite(3, 0);
|
||||
|
@ -108,8 +80,6 @@ void loop() {
|
|||
digitalWrite(A2, 1);
|
||||
digitalWrite(A4, 0);
|
||||
digitalWrite(A5, 1);
|
||||
analogWrite(10,pwmx);
|
||||
analogWrite(11,pwmx);
|
||||
}
|
||||
|
||||
if (myData.Yposition>200 && myData.Yposition<700 && myData.Xposition>200 && myData.Xposition<700) {
|
||||
|
|
|
@ -8,11 +8,10 @@ struct dataStruct {
|
|||
int Yposition;
|
||||
|
||||
} myData;
|
||||
|
||||
void setup() {
|
||||
radio.begin();
|
||||
radio.setPALevel(RF24_PA_MAX);
|
||||
radio.setChannel(50);
|
||||
radio.setChannel(125);
|
||||
radio.openWritingPipe(address);
|
||||
radio.stopListening();
|
||||
Serial.begin(9600);
|
||||
|
|
Loading…
Reference in a new issue