I need Help ( Software )

Hello,

first of all im from germany soo sry for my bad english.
Yesterday my friend wrote me a Code for my first arduinoproject an self driving car.
But i want to have the code in German not in Englisch.
My question is witch parts of the Code i can change in another language without lost the functionality. ( out of the comments)
And witch variables can i change freely without lost the functionality.
I hope for fast and helpful answers.

Thank you
Friendly greetings
CyberSpace

The Code :

#include <AFMotor.h> //import your motor shield library
#define trigPin 12 // define the pins of your sensor
#define echoPin 13
AF_DCMotor motor1(1,MOTOR12_64KHZ); // set up motors.
AF_DCMotor motor2(2, MOTOR12_8KHZ);

void setup() {
Serial.begin(9600); // begin serial communitication
Serial.println("Motor test!");
pinMode(trigPin, OUTPUT);// set the trig pin to output (Send sound waves)
pinMode(echoPin, INPUT);// set the echo pin to input (recieve sound waves)
motor1.setSpeed(105); //set the speed of the motors, between 0-255
motor2.setSpeed (105);
}

void loop() {

long duration, distance; // start the scan
digitalWrite(trigPin, LOW);
delayMicroseconds(2); // delays are required for a succesful sensor operation.
digitalWrite(trigPin, HIGH);

delayMicroseconds(10); //this delay is required as well!
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;// convert the distance to centimeters.
if (distance < 25)/*if there's an obstacle 25 centimers, ahead, do the following: */ {
Serial.println ("Close Obstacle detected!" );
Serial.println ("Obstacle Details:");
Serial.print ("Distance From Robot is " );
Serial.print ( distance);
Serial.print ( " CM!");// print out the distance in centimeters.

Serial.println (" The obstacle is declared a threat due to close distance. ");
Serial.println (" Turning !");
motor1.run(FORWARD); // Turn as long as there's an obstacle ahead.
motor2.run (BACKWARD);

}
else {
Serial.println ("No obstacle detected. going forward");
delay (15);
motor1.run(FORWARD); //if there's no obstacle ahead, Go Forward!
motor2.run(FORWARD);
}

}

My question is witch parts of the Code i can change in another language without lost the functionality.

None of it.

And witch variables can i change freely without lost the functionality.

Any of them

The code is C, C++, and Arduino library functions. This is all defined in English. Sorry!

The literal strings between double quote marks may be changed, and you may use German there.

The comments (following the // marks) may be translated into German. They are for you and are ignored by the compiler.

In the future, to post:

  1. Use CTRL-T in the Arduino IDE to autoformat your code.
  2. Paste the autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.
digitalWrite(trigPin, LOW);
delayMicroseconds(2); // delays are required for a succesful sensor operation.
digitalWrite(trigPin, HIGH);

delayMicroseconds(10); //this delay is required as well!
digitalWrite(trigPin, LOW);

Tell, your friend, the 2 microsecond delay is not required. It does nothing because trigPin is already set to LOW at the start of loop().

You can change the names of variables an functions that are defined in this sketch, except for loop() and setup().

You cannot change:

  • the names of include files
  • the names of things in external libraries
  • C++ language keywords and type names.

This means that the only thing you can change in this sketch is trigPin, echoPin, motor1, motor2, and anything in those println() quotes "like this".

Oh, and the // comments, of course.