Having issue with consistency

I have a motor opening and closing a pool cover with 2 proximity sensors for telling me if it is open or closed.
I welcome assistance with troubleshooting.

I performed a continuity test to troubleshoot if the Arduino board was fried. I unplugged all my wires and began adding things 1 component at a time.

Components:
2 (2 wire) proximity sensors
2 way selector switch (1 ground wire and two leads)
LCD output screen that came with Arduino

Things I have tried.

The one time I did get the motor to operate was when I was introducing my components. I have two proximity sensors wired to Analog Inputs and when I add the second sensor... the program will not execute the motor operation.

I have touched the leads to my 2 way selector switch for directing the motor and they work... Once I hook them up to the Arduino... I then can't manually touch the leads and try to move the motor for .. I want to say 2-3 minutes. What causes this? Is this a power surge? Loose wires?

The one time I got my program to work from an opening position to a closed position. I only had 1 of the two sensors attached.. So I turned everything off and added the second sensor. This is when the Arduino would do no more.

I attached a photo of the two wires I have ( the thick grey insulation is the wire that caused my Arduino to stop working. It was "spliced" so that I could extend the wire length.

By background is mechanical and not Electrical but I could use some troubleshooting assistance.

Thanks for your help.

I can attach the code if needed.

Hi,

I attached a photo of the two wires I have

?????? where ??????

as we cannot guess:
to help you we need some more information:

  1. Sketch or photo how you wired your project
  2. datasheet or link to your motor (what type: DC, Servo, stepper ..) and motor driver
  3. pls post your code, using the "</>" button

Never touch(*) a motor leads to any driver circuit. Connect securely first, then power up the driver circuit.

Similarly power down the driver before disconnecting any inductive load such as relay or motor.

(*) Inductive loads will generate high voltages and arcing if handled in this manner (you can even give yourself
a painful shock - with large motors you can give yourself a dangerous shock). Driver circuits don't like
arcing at their contacts, it tends to fry them.

You haven't mentioned any motor driver - you do have a motor driver?

My Code is below
Pictures of some of the Arduino are attached.
Motor is a custom 650 Series Bison Motor ( customized gearbox)
The base is something like this.
https://www.bisongear.com/printable-spec-sheet.php?sku=016-656-0054

const int motor1Pin = 12;    // H-bridge leg 1 (pin 2, 1A)
const int motor2Pin = 13;    // H-bridge leg 2 (pin 7, 2A)
const int SensorOpen = 3; //Proximity Sensor for Magnet near motor Analog 0
const int SensorClose = 5; //Proximity Sensor for Magnet at end of track Analog 1
int counter = -1;




// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 5, 4, 3, 2);

void setup() {
  
   // make sure all pins do not start or "coast"
   digitalWrite(motor1Pin, LOW);
   digitalWrite(motor2Pin, LOW);
;  
   // set all the other pins you're using as outputs:
    pinMode(motor1Pin, OUTPUT);
    pinMode(motor2Pin, OUTPUT);
    pinMode(SensorOpen, INPUT);
    pinMode(SensorClose, INPUT);
    Serial.begin(9600);
        // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD. (Will stay)
  lcd.print("Number of Cycles");
             delay(2000);
    
  }

void loop() {
        //Read the Proximity Sensor Values
    int Open = analogRead(SensorOpen); 
    int Close = analogRead(SensorClose);
     Serial.println(Open);
     Serial.println(Close);
   
      if (Close > 950) {
        //Will Stop the Motor upon trigger of sensor
        //Delay for 1 minute and reverse direction (Open the Cover)
    digitalWrite(motor1Pin, LOW);   
    delay(60000);
    digitalWrite(motor2Pin, HIGH); 
    delay(5000);
   
  }
     if (Open > 900) {
        //Will Stop the Motor upon trigger of sensor
        //Delay for 5 seconds and reverse direction (Close the Cover)
    digitalWrite(motor2Pin, LOW);
    delay(5000);
    digitalWrite(motor1Pin, HIGH); 
    counter++;
    delay(5000);
  }
    
    Serial.println(counter);

   // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of cycles since reset:
  lcd.print(counter);
     

 
 }

I must not have a motor driver. I honestly just googled the term to understand what it is. I have my switch attached to my board

Attached is the original Arduino Wiring, as I realized my modified some of the pins on my previous photo submission.

**Update After doing some thinking, I have completed a training project with an H bridge, is this the same thing? If so does that mean I need to be utilizing this chip to control the directions of the motor?

Updated Code utilizing an H bridge. I appreciate your time spent looking at my project! From what I gather I could use some more experience understanding voltage, "stepping", and terminology involving this type of sketch.

** Update as of 3:43 Server time-

const int motor1Pin = 2;    // H-bridge leg 1 (pin 7, 1A)
const int motor2Pin = 6;    // H-bridge leg 2 (pin 8, 2A)
const int enablePin = 10;   // H-bridge enable pin to power motor
const int SensorOpen = 0; //Proximity Sensor for Magnet near motor Analog 0
const int SensorClose = 1; //Proximity Sensor for Magnet at end of track Analog 1
int counter = -1;




// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 9, 5, 4, 3, 12);

void setup() {
  
   // make sure all pins do not start or "coast"
   digitalWrite(enablePin, LOW);
    
   // set all the other pins you're using as outputs:
    pinMode(motor1Pin, OUTPUT);
    pinMode(motor2Pin, OUTPUT);
    pinMode(enablePin, OUTPUT);
    pinMode(SensorOpen, INPUT);
    pinMode(SensorClose, INPUT);
    Serial.begin(9600);
        // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD. (Will stay)
  lcd.print("Number of Cycles");
             delay(2000);
    
  }

void loop() {
        //Read the Proximity Sensor Values
    int Open = analogRead(SensorOpen); 
   int Close = analogRead(SensorClose);
     Serial.println(Open);
     Serial.println(Close);
     delay(500);
     
    if (Close > 1000) {
        //Will Stop the Motor upon trigger of sensor
        //Delay and reverse direction (Open the Cover)
      digitalWrite(enablePin, LOW);
      delay(6000); // time for motor to cool down.  (Change to 1 minute)
      digitalWrite(motor1Pin, LOW);
      digitalWrite(motor2Pin, HIGH);
      analogWrite(enablePin, 255);
      delay(5000); // time to clear the sensor
   
  }
 
     if (Open > 1000) {
        //Will Stop the Motor upon trigger of sensor
        //Delay for 5 seconds and reverse direction (Close the Cover)
    digitalWrite(enablePin, LOW);
    delay(6000);  // time for motor to cool
    digitalWrite(motor2Pin, LOW);
    digitalWrite(motor1Pin, HIGH);
    analogWrite(enablePin, 255);
    delay(5000);   // time to clear the proximity sensor
    counter++;
 //   delay(23000);    // test using time instead of sensors
     
     
      
         
      delay(4000);
   //   delay(15000);
       
    
  
     }
     
    Serial.println(counter);

   // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of cycles since reset:
  lcd.print(counter);
     

 
 }

Forget abut stepping and drivers, as you have an AC motor, not, as I previously assumed, a stepper motor.
That is why it would be good if all OP_s should give as much information as possible. Now we are 6 postings and one day further and I still have not completely understood your problem and configuration.

To better understand, what your configuration really looks like:

Post a COMPLETE schematic of your project, not only fragments - with all connected devices incl. 2 sensors and let us know exactly what your goal with this project is.

I am not sure how to start a schematic as this is not my expertise. The system is fairly simple.

I have a motor operating a pool cover that opens or closes. I can use delay(x000) in my sketch to operate this machine ( open for 14 seconds and close for 24 seconds)but it is not accurate or safe enough. I have added proximity switches to indicate length of travel and tell my sketch when to switch direction.

The additional reason as to why I added that I can get this to run off of a delay, is that I know my hardware is wired correctly. I have also tested the serial printer to indicate what my proximity sensors are doing. The issue I believe is now my code?

Some questions:

  1. what exactly is the "enable pin" for?
    (note: in your code you write to it digitally and in one place with an analogue value of 255 - stay with digitalWrite as enable is either ON (HIGH) or OFF (LOW) - you are puzzling yourself mixing digital and analogue writes although it may have the same effect here)

  2. What kind of sensors are you using? (proximity is clear, but: are those of type "inductive", "capacitive" or what?) -> and why did you mention in your code as comment:

Proximity Sensor for Magnet near motor Analog 0

which might indicate a hall sensor ->
Pls post a link to the datasheet of the sensors.

  1. What kind of H-Bridge do you use? (datasheet)

  2. How do you start the "open"-process and the "close"-process (I suspect you power your Arduino and the motor and when it senses "closed position" it starts the "opening process" and vice versa, when it was in "open position" then runs the opposite direction (at least it should do so), right?

  3. You say you connected the two sensors to analogue pins of Arduino - in your code I find the following:

const int SensorOpen = 0; //Proximity Sensor for Magnet near motor Analog 0
const int SensorClose = 1; //Proximity Sensor for Magnet at end of track Analog 1

Shouldn't it be:

const int SensorOpen = A0; //Proximity Sensor for Magnet near motor Analog 0
const int SensorClose = A1; //Proximity Sensor for Magnet at end of track Analog 1

or did you really wire the sensors to D0 and D1 instead of A0 and A1 ?