Ein Roboter mit bürstenlosem Antrieb, differenzial und NRF24L01 Funk. Großflächig gebaut um ein großes Solarpanel aufzunehmen. https://gitlab.informatik.hs-fulda.de/fdai5253/roboter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.1 KiB

void manualDigitalDrive() {
bool goOn = false;
String temp_str = "T: " + String(temperature) + " Grad C";
lcdLines[5] = temp_str;
// while(!tasten.getButtonCycle(buttonL1)) {
clearCommands();
if(!tasten.getAnyPressed()) {
lcdLines[0] = "Warte...";
}
if(tasten.checkButton(buttonB) || tasten.checkButton(buttonUp)) {
pwmA = -215;
pwmB = -255;
lcdLines[0] = "geradeaus fahren";
goOn =true;
}
if(tasten.checkButton(buttonC) || tasten.checkButton(buttonDown)) {
pwmA = 100;
pwmB = 255;
lcdLines[0] = "rueckwaerts fahren";
goOn =true;
}
if(tasten.checkButton(buttonRight)) {
pwmA = -100; //rechter Motor
pwmB = 100;
lcdLines[0] = "rechts lenken";
goOn =true;
}
if(tasten.checkButton(buttonLeft)) {
pwmB = -100;
pwmA = 100;
lcdLines[0] = "links lenken";
goOn =true;
}
if(goOn) {
commands[0] = speedA;
commands[1] = highByte(pwmA);
commands[2] = lowByte(pwmA);
commands[3] = speedB;
commands[4] = highByte(pwmB);
commands[5] = lowByte(pwmB);
commands[6] = timeToDrive;
commands[7] = highByte(driveTimeout);
commands[8] = lowByte(driveTimeout);
commands[9] = goDrive;
radio.write(&commands, sizeof(commands));
goOn = false;
}
//Temperatur <3
if((unsigned long)(millis() - 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");
if((unsigned long)(micros()- start) >= 1){
err = true;
}
}
if(!err){
radio.read(&temperature, sizeof(int16_t));
}
radio.stopListening();
}
// }
// tasten.clearAllButtons();
}