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.

82 lines
2.2 KiB

  1. #include <Steuerung.h>
  2. //Informationen Joystick
  3. Joystick *joystick;
  4. const uint16_t xAxisPin = 5;
  5. const uint16_t yAxisPin = 6;
  6. const int16_t lowestJoystickValue = 0;
  7. const int16_t highestJoystickValue = 511;
  8. const int16_t spaceing = 60;
  9. //Informationen linker Motor
  10. Motor *left;
  11. const int16_t lowestPWMValueLeftMotor = -255;
  12. const int16_t highestPWMValueLeftMotor = 255;
  13. //Informationen rechter Motor
  14. Motor *right;
  15. const int16_t lowestPWMValueRightMotor = -255;
  16. const int16_t highestPWMValueRightMotor = 255;
  17. Steuerung *steuerung;
  18. void joystickInit() {
  19. joystick = new Joystick(xAxisPin, yAxisPin, lowestJoystickValue, highestJoystickValue, spaceing);
  20. left = new Motor(lowestPWMValueLeftMotor, highestPWMValueLeftMotor);
  21. right = new Motor(lowestPWMValueRightMotor, highestPWMValueRightMotor);
  22. steuerung = new Steuerung(joystick, left, right);
  23. //Serial.begin(9600);
  24. }
  25. void joystickSteuerung() {
  26. //Only updates if joystick is moved
  27. steuerung -> updateValues();
  28. //Show Values On LCD
  29. showValuesOnLCD();
  30. //SendValues
  31. send();
  32. }
  33. void showValuesOnLCD(){
  34. //TODO BUILD STRING
  35. //lcd.clear();
  36. lcd.gotoXY(0,0);
  37. lcd.print(" ");
  38. lcd.gotoXY(0,0);
  39. lcd.print("WithLib");
  40. lcd.gotoXY(0,1);
  41. lcd.print(" ");
  42. lcd.gotoXY(0,1);
  43. lcd.print("LeftPWM: ");
  44. lcd.print(left -> PWMValue);
  45. lcd.gotoXY(0,2);
  46. lcd.print(" ");
  47. lcd.gotoXY(0,2);
  48. lcd.print("RightPWM: ");
  49. lcd.print(right -> PWMValue);
  50. }
  51. void send(){
  52. commands[0] = speedA;
  53. commands[1] = highByte(left -> PWMValue);
  54. commands[2] = lowByte(left -> PWMValue);
  55. commands[3] = speedB;
  56. commands[4] = highByte(right -> PWMValue);
  57. commands[5] = lowByte(right -> PWMValue);
  58. commands[6] = timeToDrive;
  59. commands[7] = highByte(driveTimeout);
  60. commands[8] = lowByte(driveTimeout);
  61. commands[9] = goDrive;
  62. commands[10] = getTemp;
  63. commands[11] = highByte(temperature);
  64. commands[12] = lowByte(temperature);
  65. commands[13] = getTemp;
  66. commands[14] = highByte(distance);
  67. commands[15] = lowByte(distance);
  68. radio.write(&commands, sizeof(commands));
  69. }