Assignment 5

 

For this project we wanted to use the linear motor to create shadow software the IMA ghost. The idea is to install the ghost-shaped plywood on the motor and put a halogen light between them to cast slightly distorted shadows on the wall to mimic a horror film vibe.

Two of our partners laser cut the ghost, and me and the other member made the base of the motors and the light.  

  

We struggled with how to best position the motors so they are titled in an angle that cast the shadows the way we wanted. We thought about building two separate slop-like base for each motor but find this method hard to keep motors from slipping off since they are quite heavy, and after dome discussion we decided to build a box that has three holes on top, two for the motors and one for the the light. The good thing about building a box is that we could make the holes slightly wider than the motor and self-adjust the angles when tilting them, and it’s also good for hiding the wires.

But then there’s the problem of the distance between the two holes and the their distance to the light. We first went to the bathroom with rulers, closed all the light, and tested the optimal length. We then calculated the length, width the box, and the depth and the diameter of the holes based on the measurement of the motor, and cut out the box with two holes. We then installed the ghosts on the motor and tested them with the box and the light. It’s easy to think that the light should be situated on the intersection of the diagonal lines of the box if the ghosts are on the two opposite corner, but the best spot it’s in fact somewhere more far away form the two motors. After we sized up a good position for the light we put a small hole with a drill.

Here’s a video of us adjusting the position of the light.

 

It also took us some time to figure out how to present it. We want a corner with two white walls but sadly two sides of our classroom are glass. We thought about moving the black cart in the corner next to the projector screen but it turned out to be too heavy to be moved around, so we decided to but the box on a table and one of the corner in the back of the room, and use a white board to act as the second wall and also to block the light coming in form the glass door.

For the finishing steps, we painted the ghosts white so fits the concept better, and placed two small pieces of plywood behind the halogen light so it doesn’t blind people’s eye when looking at the project. 

We did not expect the bar of the motor to be rotating as well while moving up and down, so after a while the shadows of the ghost would look a bit lopsided. But the work looks satisfying overall. 

Here is the code:

// modified from: https://lastminuteengineers.com/l298n-dc-stepper-driver-arduino-tutorial/ 

// Motor A connections
int enA = 9;
int in1 = 8;
int in2 = 7;

int enB = 5;
int in3 = 4;
int in4 = 2;

void setup() {
	// Set all the motor control pins to outputs
	pinMode(enA, OUTPUT);
	pinMode(in1, OUTPUT);
	pinMode(in2, OUTPUT);
  pinMode(enB, OUTPUT);
	pinMode(in3, OUTPUT);
	pinMode(in4, OUTPUT);
	
	// Turn off motors - Initial state
	digitalWrite(in1, LOW);
	digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
	digitalWrite(in4, LOW);
}

void loop() {
	directionControl();
	delay(1000);
	speedControl();
	delay(1000);
}

// This function lets you control spinning direction of motors
void directionControl() {
	// Set motors to maximum speed
	// For PWM maximum possible values are 0 to 255
	analogWrite(enA, 255);
  analogWrite(enB, 255);

	// Turn on motor A & B
	digitalWrite(in1, HIGH);
	digitalWrite(in2, LOW);
  digitalWrite(in3, HIGH);
	digitalWrite(in4, LOW);
	delay(4000);
	
	// Now change motor directions
	digitalWrite(in1, LOW);
	digitalWrite(in2, HIGH);
  digitalWrite(in3, LOW);
	digitalWrite(in4, HIGH);
	delay(4000);
	
	// Turn off motors
	digitalWrite(in1, LOW);
	digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
	digitalWrite(in4, LOW);
}

// This function lets you control speed of the motors
void speedControl() {
	// Turn on motors
	digitalWrite(in1, LOW);
	digitalWrite(in2, HIGH);
  digitalWrite(in3, LOW);
	digitalWrite(in4, HIGH);
  
	
	// Accelerate from zero to maximum speed
	for (int i = 0; i < 256; i++) { analogWrite(enA, i); analogWrite(enB, i); delay(50); } delay(1000); // Decelerate from maximum speed to zero for (int i = 255; i >= 0; --i) {
		analogWrite(enA, i);
    analogWrite(enB, i);
		delay(50);
	}
  delay(1000);
	
	// Now turn off motors
	digitalWrite(in1, LOW);
	digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
	digitalWrite(in4, LOW);
} 

Leave a Reply

Your email address will not be published. Required fields are marked *