Browse Source

Code bereinigt

master
Yves Ehrlich 5 years ago
parent
commit
7f77bde5c6
  1. 22
      Code/miniRobot/miniRobot.ino

22
Code/miniRobot/miniRobot.ino

@ -37,21 +37,9 @@ const byte address2[6] = "00002";
#define getDistance 10 //Abstand zu Objekten #define getDistance 10 //Abstand zu Objekten
//Motortreiber //Motortreiber
//#include <MX1508.h>
#include <L298N.h> #include <L298N.h>
#define BEEP 14
/*
#define PWM_PINA 10
#define PINA 8
#define PWM_PINB 9
#define PINB 7
#define NUMPWM 1
#define RESOLUTION 255 */
//MX1508 motorA(PWM_PINA,PINA, FAST_DECAY, NUMPWM);
//MX1508 motorB(PWM_PINB,PINB, FAST_DECAY, NUMPWM);
#define BEEP 14 //Motoren drehen bei diesem PWM Wert nicht, aber fiepen
L298N drive; L298N drive;
@ -61,8 +49,8 @@ bool forwardA = true;
bool forwardB = true; bool forwardB = true;
volatile bool driveOn = false; volatile bool driveOn = false;
volatile long driveTimeout = 0;
volatile long driveTimeDiff = 0;
volatile uint32_t driveTimeout = 0;
volatile uint32_t driveTimeDiff = 0;
volatile bool startNewMeasurement = true; volatile bool startNewMeasurement = true;
@ -106,7 +94,7 @@ void loop() {
// Serial.println("berechnen"); // Serial.println("berechnen");
distance = calculateDistance(); distance = calculateDistance();
} }
//wurden Kommandos empfangen?
if (radio.available()) { if (radio.available()) {
radio.read(&commands, sizeof(commands)); radio.read(&commands, sizeof(commands));
commandInterpretation(); commandInterpretation();
@ -182,7 +170,7 @@ void commandInterpretation() {
uint16_t driveTime = 0; uint16_t driveTime = 0;
driveTime = (0xFF00 & (commands[i+1] << 8)); driveTime = (0xFF00 & (commands[i+1] << 8));
driveTime |= (0x00FF & commands[i+2]); driveTime |= (0x00FF & commands[i+2]);
driveTimeout = (long)driveTime;
driveTimeout = (uint32_t)driveTime;
driveTimeDiff = millis(); driveTimeDiff = millis();
//Serial.println(driveTimeout); //Serial.println(driveTimeout);
break; break;

Loading…
Cancel
Save