nickg
5 years ago
5 changed files with 48 additions and 40 deletions
-
5Code/miniRobot/miniRobot.ino
-
21Code/miniRobot/temperatureDistance.ino
-
3Code/miniRobotRC/_main.ino
-
28Code/miniRobotRC/fahrsteuerung_old.ino
-
29Code/miniRobotRC/temp.ino
@ -0,0 +1,29 @@ |
|||||
|
//Temperatur <3
|
||||
|
void updateTemp(){ |
||||
|
unsigned long currentMillis = millis(); |
||||
|
if((unsigned long)(currentMillis - temp_time) >= 1000){ // jede Sekunden
|
||||
|
temp_time = millis(); |
||||
|
bool err = false; |
||||
|
clearCommands(); |
||||
|
|
||||
|
commands[0] = getTemp; |
||||
|
radio.write(&commands, sizeof(commands) && !err); |
||||
|
unsigned long start = micros(); |
||||
|
radio.startListening(); |
||||
|
while(!radio.available()){ |
||||
|
//Serial.println("nix");
|
||||
|
unsigned long currentMicros = micros(); |
||||
|
if((unsigned long)(currentMicros - start) >= 1){ |
||||
|
|
||||
|
err = true; |
||||
|
} |
||||
|
} |
||||
|
if(!err){ |
||||
|
int16_t readData; |
||||
|
radio.read(&readData, sizeof(int16_t)); |
||||
|
temperature = readData; |
||||
|
} |
||||
|
radio.stopListening(); |
||||
|
clearCommands(); |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue