Browse Source

neues

master
Yves Ehrlich 5 years ago
parent
commit
ce5f1fa00c
  1. 96
      Code/miniRobotRC/_main.ino
  2. 9
      Code/miniRobotRC/miniRobotRC.ino

96
Code/miniRobotRC/_main.ino

@ -12,104 +12,24 @@ void setup() {
remoteControlInit(); remoteControlInit();
funkInit(); funkInit();
Serial.begin(115200); Serial.begin(115200);
driveTimeout = 50;
/*
commands[0] = speedA;
commands[1] = 0xFF & (pwmA >> 8);
commands[2] = 0xFF & pwmA;
driveTimeout = 10;
commands[3] = speedB;
commands[4] = 0xFF & (pwmB >> 8);
commands[5] = 0xFF & pwmB;
commands[6] = goDrive;
commands[9] = timeToDrive;
commands[10] = 0xFF & (driveTimeout >> 8);
commands[11] = 0xFF & driveTimeout; */
clearCommands(); clearCommands();
} }
void loop() { void loop() {
//char text[32] = "Hello";
// radio.write(&commands, sizeof(commands));
//lcdMenu(); //lcdMenu();
//delay(10000);
manualDrive();
while(!tasten.getButtonCycle(buttonStart)) {
manualDigitalDrive();
}
tasten.clearButton(buttonStart);
while(!tasten.getButtonCycle(buttonStart)) motorMapping();
tasten.clearButton(buttonStart);
} }
void lcdMenu() { void lcdMenu() {
lcd.println("Platzhalter"); lcd.println("Platzhalter");
if(tasten.getButtonCycle(buttonUp)) {
tasten.clearAllButtons();
}
if(tasten.getButtonCycle(buttonDown)) {
tasten.clearAllButtons();
}
}
void manualDrive() {
bool goOn = false;
while(!tasten.getButtonCycle(buttonStart)) {
clearCommands();
if(!tasten.getAnyPressed()) {
lcd.clear();
lcd.println("Warte...");
}
if(tasten.checkButton(buttonB) || tasten.checkButton(buttonUp)) {
pwmA = -215;
pwmB = -255;
// tasten.clearButton(buttonB);
lcd.clear();
lcd.println("geradeaus fahren");
goOn =true;
}
if(tasten.checkButton(buttonC) || tasten.checkButton(buttonDown)) {
pwmA = 100;
pwmB = 255;
// tasten.clearButton(buttonC);
lcd.clear();
lcd.println("rueckwaerts fahren");
goOn =true;
}
if(tasten.checkButton(buttonRight)) {
pwmA = -100; //rechter Motor
pwmB = 100;
//tasten.clearButton(buttonRight);
lcd.clear();
lcd.println("rechts lenken");
goOn =true;
}
if(tasten.checkButton(buttonLeft)) {
pwmB = -100;
pwmA = 100;
//tasten.clearButton(buttonLeft);
lcd.clear();
lcd.println("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;
}
}
tasten.clearAllButtons();
}
ISR(TIMER2_COMPA_vect) { // called by timer2
tasten.checkButtons(); //Aufruf 1-mal pro Millisekunde
} }

9
Code/miniRobotRC/miniRobotRC.ino

@ -1,4 +1,3 @@
//template
#include <PCD8544_SPI.h> #include <PCD8544_SPI.h>
#include <shiftRegButtonLib.h> #include <shiftRegButtonLib.h>
#include <myInterrupts.h> #include <myInterrupts.h>
@ -34,9 +33,7 @@ bool forwardA = true;
bool forwardB = true; bool forwardB = true;
bool driveOn = false; bool driveOn = false;
uint16_t driveTimeout = 0; uint16_t driveTimeout = 0;
//#define highByte(x) ( (x) >> (8) ) // keep upper 8 bits
//#define lowByte(x) ( (x) & (0xff) ) // keep lower 8 bits
//Funk
#include <SPI.h> #include <SPI.h>
#include <nRF24L01.h> #include <nRF24L01.h>
#include <RF24.h> #include <RF24.h>
@ -46,7 +43,7 @@ RF24 radio(A2, A3); // CE, CSN
const byte address[6] = "00001"; const byte address[6] = "00001";
uint8_t commands[32]; uint8_t commands[32];
/*
const String mainMenu[] = { const String mainMenu[] = {
"fahren", //0 "fahren", //0
"stoppen", //1 "stoppen", //1
@ -65,4 +62,4 @@ const String subMenuEntry0[] = {
"Speed A", "Speed A",
"Speed B", "Speed B",
"Starten" "Starten"
};
}; */
Loading…
Cancel
Save