Project with Ultrasonic Sensor, Stepmotor and Servomotor

hi Guys,
I currently have a project going on for school. I'm supposed to build a house with a door that is opened by a servo motor and gets the signal through the ultrasonic sensor. There should be a table in the house, the tabletop of which should rotate continuously. I am not able to write a program for it, can someone help me? My current program without the stepper motor:

#include <Servo.h>
#include <Stepper.h>
int SPU = 2048;
Stepper Motor(SPU, 3,5,4,6);
Servo myservo;
int pos = 20;
const int trigPin = 9;
const int echoPin = 10 ;
const int led = 13;

long duration;
float distance;

void setup()
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);

void loop()

digitalWrite(trigPin, LOW);
digitalWrite(trigPin, HIGH);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distance = 0.034*(duration/2);
if (distance < 27)

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

If you get errors when compiling please copy them from the IDE using the "Copy error messages" button and paste the clipboard here in code tags

@clsslc, your topic was moved to a more suitable location on the forum.

Van you please spend some time reading How to get the best out of this forum, next edit your post and apply the code tags to your code as described in the link.

Vad kind of school gives You this kind of work before teaching programming?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.