Help with Projector Ceiling POP Nema11+MB6600

Hello Guys I am new here and with Arduino, I am working on my home teather system and I did built a case with 2 Nema 11 Linear motors and 2 MB6600 as a controlles , One of my friend tried to code for me since I don't know how to code, I just need a simple coding that makes my motor
goes up and down so the projector can go inside the ceiling and a regular switch on and off , my project right now motors sometimes goe very noise they dont go in stand by when they are not using so they stand by overheating and also motors can't identify it limits when its up or down position, if anyone can help it will be very appreciated I will post some pics

Thanks

Manny



Please post the formatted code and remember using code tags.

// Define the pin connections
const int stepPin = 3;   // PUL+ connected to pin 2
const int dirPin = 4;    // DIR+ connected to pin 3
const int enablePin = 5; // ENA+ connected to pin 4 (optional)
const int buttonPin = 2; // Button pin connected to pin 5

// Motor settings
const int stepsPerRevolution = 200;  // Depends on your motor's step count per revolution

void setup() {
  // Set the motor control pins as output
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  
  // Set the button pin as input
  pinMode(buttonPin, INPUT_PULLUP); // Using internal pull-up resistor
  
  // Enable the motor driver (optional)
  digitalWrite(enablePin, LOW);  // LOW to enable TB6600, HIGH to disable

  // Initialize Serial Monitor
  Serial.begin(9600);
}

void loop() {
  // Check if the button is pressed
  if (digitalRead(buttonPin) == LOW) {
    Serial.println("Button pressed, moving motor...");
    
    // Set the motor direction (HIGH for one direction, LOW for the other)
    digitalWrite(dirPin, HIGH);  // Change to LOW for opposite direction
    
    // Move the motor for one revolution
    for (int i = 0; i < stepsPerRevolution; i++) {
      // Pulse the step pin
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(500);   // Adjust speed by changing the delay
      digitalWrite(stepPin, LOW);
      delayMicroseconds(500);   // Adjust speed by changing the delay
    }
    
    // Debounce delay to prevent multiple triggers
    delay(500); // Adjust delay to prevent repeated button presses
  }
}

Thanks.
How do You make sure that the 2 steppers are at the same level? If one has been missing steps there will be a mechanical lock.

I suggest increasing the second delay, in the foor loop to 10000. The pulsrate might be to high and steps might be lost.
A library providing acceleration might be needed for "full speed".

You can surely reduce the button debounce delay to 50 but it's not the reason for the trouble.

When it runs we can look at the limit switches.

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