diff --git a/Code/miniRobot/miniRobot.ino b/Code/miniRobot/miniRobot.ino index 53de7dd..4f94f72 100644 --- a/Code/miniRobot/miniRobot.ino +++ b/Code/miniRobot/miniRobot.ino @@ -13,7 +13,7 @@ RF24 radio(A0, 3); // CE, CSN byte commands[32]; //byte 0 = command long timer; -int temperature; +int16_t temperature; int distance = 0; void inline clearCommands() { @@ -78,7 +78,7 @@ void setup() { //Temperatur- und Abstandsmessung tempDistSetup(); - setEchoPins(0, 0); //Setze die pins für den Abstandsensor aus denen gelesenw erden soll das erster ist der Trigger-, das zweite der Echopin + setEchoPins(16, 5); //16: A2, 5: D5 timer = millis(); } @@ -100,8 +100,8 @@ void loop() { temperature = dallas(4, 0); if(millis() - timer >= 100){ - measureDistance(); - timer = millis(); + measureDistance(); + timer = millis(); } distance = calculateDistance(); @@ -149,10 +149,9 @@ void commandInterpretation() { driveOn = false; break; } - case getTemp : { - int temp5; - temp5 = (0xFF00 & (commands[i+1] << 8)); - temp5 |= (0x00FF & commands[i+2]); + case getTemp : { + + radio.write(&temperature, sizeof(temperature)); break; } case timeToDrive : { @@ -169,6 +168,7 @@ void commandInterpretation() { forwardA = true; forwardB = true; driveOn = false; */ + break; } } diff --git a/Code/miniRobot/temperatureDistance.ino b/Code/miniRobot/temperatureDistance.ino index 625019a..216f1dd 100644 --- a/Code/miniRobot/temperatureDistance.ino +++ b/Code/miniRobot/temperatureDistance.ino @@ -36,13 +36,13 @@ int calculateDistance(){ void measureDistance(){ - PORTD |= (1<