|
@ -23,6 +23,7 @@ void inline clearCommands() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const byte address[6] = "00001"; |
|
|
const byte address[6] = "00001"; |
|
|
|
|
|
const byte address2[6] = "00002"; |
|
|
//Kommandos
|
|
|
//Kommandos
|
|
|
#define nothing 9 //reset/nichts tun
|
|
|
#define nothing 9 //reset/nichts tun
|
|
|
#define speedA 1 // set speed A + speed
|
|
|
#define speedA 1 // set speed A + speed
|
|
@ -60,7 +61,7 @@ bool forwardA = true; |
|
|
bool forwardB = true; |
|
|
bool forwardB = true; |
|
|
volatile bool driveOn = false; |
|
|
volatile bool driveOn = false; |
|
|
|
|
|
|
|
|
int temperatur = 0; |
|
|
|
|
|
|
|
|
int16_t temperatur = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
volatile long driveTimeout = 0; |
|
|
volatile long driveTimeout = 0; |
|
@ -71,6 +72,7 @@ void setup() { |
|
|
// motorA.setPWM16(2,RESOLUTION);
|
|
|
// motorA.setPWM16(2,RESOLUTION);
|
|
|
// motorB.setPWM16(2,RESOLUTION);
|
|
|
// motorB.setPWM16(2,RESOLUTION);
|
|
|
radio.begin(); |
|
|
radio.begin(); |
|
|
|
|
|
radio.openWritingPipe(address2); |
|
|
radio.openReadingPipe(0, address); |
|
|
radio.openReadingPipe(0, address); |
|
|
radio.setPALevel(RF24_PA_MAX); |
|
|
radio.setPALevel(RF24_PA_MAX); |
|
|
radio.startListening(); |
|
|
radio.startListening(); |
|
@ -83,6 +85,7 @@ void setup() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void loop() { |
|
|
void loop() { |
|
|
|
|
|
Serial.println(temperature); |
|
|
if (radio.available()) { |
|
|
if (radio.available()) { |
|
|
radio.read(&commands, sizeof(commands)); |
|
|
radio.read(&commands, sizeof(commands)); |
|
|
commandInterpretation(); |
|
|
commandInterpretation(); |
|
@ -92,9 +95,11 @@ void loop() { |
|
|
pwmA = 0; |
|
|
pwmA = 0; |
|
|
pwmB = 0; |
|
|
pwmB = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
drive.setPWM_A(pwmA); |
|
|
drive.setPWM_A(pwmA); |
|
|
drive.setPWM_B(pwmB); |
|
|
drive.setPWM_B(pwmB); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Temperatur- und Abstandsmessung
|
|
|
//Temperatur- und Abstandsmessung
|
|
|
|
|
|
|
|
|
temperature = dallas(4, 0); |
|
|
temperature = dallas(4, 0); |
|
@ -150,8 +155,10 @@ void commandInterpretation() { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
case getTemp : { |
|
|
case getTemp : { |
|
|
|
|
|
|
|
|
radio.write(&temperature, sizeof(temperature)); |
|
|
|
|
|
|
|
|
Serial.println("Senden!"); |
|
|
|
|
|
radio.stopListening(); |
|
|
|
|
|
radio.write(&temperature, sizeof(int16_t)); |
|
|
|
|
|
radio.startListening(); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
case timeToDrive : { |
|
|
case timeToDrive : { |
|
|