Thanks.
Tell us in detail what it actually does.
Well it vibrates and the diodes are going on/off.
You have not told us exactly what you were hoping would happen when you combined the programs.
My main objective is experimenting. In this case I wanted the stepper to turn clockwise a certain amount and if the next distance measurement shows a value below DistLimit then the next time it should turn counterclockwise.
Your combined code does not print the value from the sensor - are you sure you are getting a useful value?
I know it because at a certain distance I can read 'counterclokwise' on the serial.
I suspect it is a mistake that you also have
Absolutely YES 
But that does not change anything about the basic problem. I wouldn't mind if it run all the same direction if it runs at all 
I am just wondering how can the same setup work for both components standalone but not in combination, at least as the stepper ist concerned.
For the future include short programs in your Post. Use the Code button </>. People reading on tablets can't open attachments.
Thanks for the info. I am still learning...
Here are the three programs used on the same unchanged setup:
Stepper
//www.elegoo.com
//2016.12.12
/*
Stepper Motor Control - one revolution
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
The motor should revolve one revolution in one direction, then
one revolution in the other direction.
*/
#include <Stepper.h>
const int stepsPerRevolution = 1800; // change this to fit the number of steps per revolution
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
void setup() {
// set the speed at 20 rpm:
myStepper.setSpeed(20);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);
// step one revolution in the other direction:
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}
Ultrasonics:
//www.elegoo.com
//2016.12.08
#include "SR04.h"
#define TRIG_PIN 5//ursprüngl. 12
#define ECHO_PIN 6//ursprüngl. 11
SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
long a;
void setup() {
Serial.begin(9600);
delay(1000);
}
void loop() {
a=sr04.DistanceAvg(30, 3);
Serial.println(a);
//Serial.println(" cm");
delay(100);
}
my combination of the two (mistake in rotation removed):
/*
* ursprüngliche Idee: ultrasonic radar
*
* now: change the direction of the stepper when the measures distnce is below a certain thteshhold
*/
#include "SR04.h"
#include <Stepper.h>
const int TRIG_PIN = 5;
const int ECHO_PIN = 6;
const int stepsPerRevolution = 1500;
Stepper myStepper(stepsPerRevolution, 8,9,10,11);
SR04 sr04 = SR04(ECHO_PIN, TRIG_PIN);
void setup() {
// put your setup code here, to run once:
myStepper.setSpeed(30);
Serial.begin(9600);
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
long a = sr04.DistanceAvg(30,3);
const int rotation = 1000;
const int DistLimit = 50;
if (a<DistLimit) {
Serial.println("clockwise");
myStepper.step(rotation);
} else {
Serial.println("counterclockwise");
myStepper.step(-rotation);
}
delay(500);
}