watch the video first

so the goal here was to build a Soap/Sanitiser without using the "servo motor method" instead go with another approach.

this is actually pretty straightforward built,

first, you need to print these parts and gather all the electronics components that we need.

this is actually pretty straightforward built,

first, you need to print these parts and gather all the electronics components that we need.

Parts that you need to 3D print for CNC rail -

1. END x1

2. Motor End x1

for rest of the built

3. Upper x1

4. LOWER x1

5. Lid x1

6. backbone bracket x1

7. Front support x1

8. back support x1

9. base x1 (or just use any plywood as the base)

for the CNC rail built instruction, watch this video

(I've just changed the carriage of the linear rail with a different one which has two holes on it for attaching the lever )

also, you might need to make a custom soap bottle holder as these bottles are not really universal.

int trigPin = 11; 
int echoPin = 10; 

const int stepPin = 13; 
const int dirPin = 12; 

void setup()
{  
pinMode(trigPin, OUTPUT); //Sensor
pinMode(echoPin, INPUT); //Sensor  
pinMode(stepPin,OUTPUT); // Step
pinMode(dirPin,OUTPUT); // Dir
Serial.begin(9600);
} 

void loop(){
  

long duration, distance;
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(5);
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 distance = (duration/2) / 29.1;
 Serial.print ("cm ");
 Serial.print (distance);


if (distance < 30)
{
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
  // Makes 300 pulses for making one full cycle rotation
  for(int x = 0; x < 250; x++) {
    digitalWrite(stepPin,HIGH); 
    delayMicroseconds(600); 
    digitalWrite(stepPin,LOW); 
    delayMicroseconds(600); 
  }
delay(1000); // One second delay
  
  digitalWrite(dirPin,LOW); //Changes the rotations direction
  // Makes 300 pulses for making two full cycle rotation
  for(int x = 0; x < 250; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(600);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(600);
  }
}
}
Credits