pleasedontcode

Labyrinth Navigation rev_01

Nov 24th, 2025
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Labyrinth Navigation
  13.     - Source Code NOT compiled for: Arduino Mega
  14.     - Source Code created on: 2025-11-25 00:33:46
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* so how can i fix this code so that the car take */
  21.     /* the hole track knowing that the path between the */
  22.     /* both walls 60cm and you can only fix the code in */
  23.     /* custom functions.h file , the problem now as you */
  24.     /* can see in the photo the tof senor or the */
  25.     /* ServoSearch */
  26. /****** END SYSTEM REQUIREMENTS *****/
  27.  
  28.  
  29. /* START CODE */
  30.  
  31. /****** DEFINITION OF LIBRARIES *****/
  32. #include <nRF24-SOLDERED.h>     //https://github.com/SolderedElectronics/Soldered-nRF24-Radio-Module-Arduino-Library
  33.  
  34. /****** FUNCTION PROTOTYPES *****/
  35. void setup(void);
  36. void loop(void);
  37.  
  38. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  39.  
  40. /* MERGED CODE START */
  41.  
  42. /* START CODE */
  43.  
  44. /****** DEFINITION OF LIBRARIES *****/
  45. #include <nRF24-SOLDERED.h>     //https://github.com/SolderedElectronics/Soldered-nRF24-Radio-Module-Arduino-Library
  46.  
  47. /****** FUNCTION PROTOTYPES *****/
  48. void setup(void);
  49. void loop(void);
  50.  
  51. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  52.  
  53. /* USER_CODE START */
  54. /***************************************************
  55.  ________  ___  _________  ________    _______    
  56. |\   __  \|\  \|\___   ___\\   ____\  /  ___  \    
  57. \ \  \|\ /\ \  \|___ \  \_\ \  \___|_/__/|_/  /|  
  58.  \ \   __  \ \  \   \ \  \ \ \_____  \__|//  / /  
  59.   \ \  \|\  \ \  \   \ \  \ \|____|\  \  /  /_/__  
  60.    \ \_____\ \__\   \ \__\  ____\_\  \|\________\
  61.     \|_____|\|__|    \|__| |\_________\\|_______|
  62.                              \|_________|          
  63.                                                        
  64.   Name:
  65.   <Hier kommt der Name des Projekts>
  66.  
  67.   Description:
  68.   <Hier kommt was dieses Skript macht>
  69.  
  70.  
  71.   Author:
  72.   Jan-Luca Diepholz  
  73.  
  74. **************************************************/
  75. #define DEBUG_SERIAL
  76. // #define WIFI_COMMUNICATION
  77.  
  78. #ifdef DEBUG_SERIAL
  79. #define _println_(x) Serial.println(x)
  80. #define _print_(x) Serial.print(x)
  81. #else
  82. #ifdef WIFI_COMMUNICATION
  83. #define _println_(x) Serial3.println(x)
  84. #define _print_(x) Serial3.print(x)
  85. #else
  86. #define _println_(x)
  87. #define _print_(x)
  88. #endif
  89. #endif
  90.  
  91. #include "config.h"
  92. #include "basic_functions.h"
  93. #include "custom_config.h"
  94. #include "custom_functions.h"
  95.  
  96. void setup(){
  97.     // Hier wird entschieden wie die Serielle Kommunikation vom Mega erfolgen soll. Weiteres siehe in config.h
  98.     #ifdef DEBUG_SERIAL
  99.     Serial.begin(115200);
  100.     #endif
  101.     #ifdef WIFI_COMMUNICATION
  102.     Serial3.begin(115200);
  103.     #endif
  104.  
  105.     // Initialisierung der optischen Time-of-Flight Sensoren
  106.     tof_controller.init();
  107.  
  108.     // Starten der I2C Kommunikation
  109.     Wire.begin();
  110.     Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties
  111.  
  112.     // Initialisierung der LED-Streifen
  113.     front_strip.init();
  114.     back_strip.init();
  115.     left_strip.init();
  116.     right_strip.init();
  117.  
  118.     // Initialisierung der IMU inkl. Lichtspiel
  119.     imu.init();
  120.     start = millis();
  121.     _println_("Waiting for IMU getting ready. Please do not move the car!");
  122.     _print_("Waiting");
  123.     set_led_color(255,0,0);
  124.     for (int k=0; k<13; k++){
  125.         for (int i=0; i<FRONT_LED_NUM; i++){
  126.             front_strip.set_pixel_color(i,thk_LedStripController::Color(red, green, blue));
  127.             front_strip.show();
  128.             delay(500/FRONT_LED_NUM);
  129.             _print_(".");
  130.         }
  131.         for (int i=0; i<FRONT_LED_NUM; i++){
  132.             front_strip.set_pixel_color(i,thk_LedStripController::Color(0, 0, 0));
  133.             front_strip.show();
  134.             delay(500/FRONT_LED_NUM);
  135.             _print_(".");
  136.         }
  137.         red -= 20;  
  138.         green += 20;  
  139.     }
  140.  
  141.     // Pin deklaration der Ultraschallsensoren
  142.     pinMode(TRIGF, OUTPUT);
  143.     pinMode(TRIGB, OUTPUT);
  144.     pinMode(ECHOF, INPUT);
  145.     pinMode(ECHOB, INPUT);
  146.  
  147.     // Initialisierung des Motors
  148.     Motor.init();    
  149.  
  150.     // Initialisierung der Servomotoren
  151.     ServoSteer.begin();
  152.     ServoSearch.begin();
  153.  
  154.     // Initialisierung abgeschlossen
  155.     _println_("Ready!");
  156.     buzzer_signal(350, 2, 100);
  157.    
  158.     set_led_color(0,100,0);
  159.     all_led_blink(2,200);
  160. }
  161.  
  162. void loop(){
  163.   Labyrinth();
  164. }
  165.  
  166. /* USER_CODE END */
  167.  
  168. /* MERGED CODE END */
  169.  
  170. /* END CODE */
  171.  
Advertisement
Add Comment
Please, Sign In to add comment