Skip to content
Snippets Groups Projects
Robotcar_functions.h 21.24 KiB
/***************************************************
   ________  ___  _________  ________    _____
  |\   __  \|\  \|\___   ___\\   ____\  / __  \
  \ \  \|\ /\ \  \|___ \  \_\ \  \___|_|\/_|\  \
   \ \   __  \ \  \   \ \  \ \ \_____  \|/ \ \  \
    \ \  \|\  \ \  \   \ \  \ \|____|\  \   \ \  \
     \ \_______\ \__\   \ \__\  ____\_\  \   \ \__\
      \|_______|\|__|    \|__| |\_________\   \|__|
                                \|_________|
  Name:
  BitS1 v2

  Author:
  Prof. Kamau
  Jannis Kampmann
  Timo Altan
  IFK TH Köln

  Last Modified:
  22.12.2023
    backward_factor and search_factor needs revisit
    Fall 8.1 & 8.2 if and else conditions adapted
    MOTOR_IN1 & 2 changed to PIN7
    MOTOR_IN3 & 4 changed to PIN8
    check_voltage() changed from quantity sensitive to time sensitive (2000ms)
  21.08.2023
    Switch from libraries "DeviceDriverSet_xxx0" to "thk-motor-driver-v2.0" & "MPU6050_getdata" to "thk_imu-v2.0"
  08 September 2022
    improvement outline / format
  15 Juli 2022
    Recoding all functions

**************************************************/

#define Key_pin 2
#define RGBLed_pin 4
#define Echo_pin 12
#define Trig_pin 13
#define OpticSensorR A0
#define OpticSensorM A1
#define OpticSensorL A2
#define Voltage_pin A3
#define NUM_LEDS 60

const int MOTOR_COUNT = 1;
const int MOTOR_STBY = 3;
const int MOTOR_PWM_A = 5;
const int MOTOR_IN1 = 7;
const int MOTOR_IN2 = 7;
const int MOTOR_PWM_B = 6;
const int MOTOR_IN3 = 8;
const int MOTOR_IN4 = 8;

thk_MotorDriverTB6612FNG motorR(MOTOR_COUNT, MOTOR_STBY, MOTOR_PWM_A, MOTOR_IN1, MOTOR_IN2, 0, 0, 0);
thk_MotorDriverTB6612FNG motorL(MOTOR_COUNT, MOTOR_STBY, MOTOR_PWM_B, MOTOR_IN3, MOTOR_IN4, 0, 0, 0);

const int INTERRUPT_PIN = 0;   // Wenn kein Interrupt Pin angeschlossen ist, dann Interrupt Pin gleich 0 setzen.
thk_IMU imu(INTERRUPT_PIN);

extern unsigned long start_time = 0;
char commandline_input = 'E';
char last_direction = 'D';
int commandline_output = 3;
int modecounter;
int obstacle_velocity = 0;
int no_reflection = 950;
int divisor = 1000;
int rest = divisor / 2;
int voltagetimer = 0;
boolean mode_changed = false;