This post marks the end of the Jack Skellington project. Because the project deadline is tomorrow, this post serves as a synopsis of the results of this group's efforts.
Jack's body (the skeleton) was constructed and adhered to the pedestal that will hold the box containing Jack's head. The box was also constructed that will house the scissor jack and Jack's head. The expected arrival date of Jack's suit was Friday, two days past the project deadline. As a result, the group had to compromise and purchase a black cloth to dress Jack's body.
The code that will control the movement of Jack's jaw and the elevation of his head was finalized; in addition, the circuit board that allows the code on the Arduino board to control the motors and LEDs was completed. In order to make the code operational, it had to be worked on in snippets. The code controlling the servo motor had to be written apart from the code that controlled the stepper motor. By initially writing these parts of the code in separate files, they could be individually tested for errors before incorporating them into one cohesive program. A portion of that program is displayed below:
It took longer to get the stepper and servo motors to operate as desired, so there was not enough time to include the audio amplifier circuit or the and speaker necessary to make Jack speak or the LEDs to illuminate Jack's eyes. The group opted to focus on ensuring that the movement of the greeter was polished and reliable, as opposed to spending time adding a new feature while neglecting to make any part of the apparatus fully functional.
Going into tomorrow's presentation, there are two main aspects of the current design with the potential to fail. The first part of the design that currently performs unreliably is the PIR sensor. This sensor is somewhat reliable in dark conditions, but in brightly lit rooms it struggles to detect when a person is passing in front of it. A toilet paper roll was taped to this sensor in an attempt to decrease the amount of environmental light that could interfere with the sensor, but it failed to make a significant difference.
The second unreliable part of the design is the servo motor, because it broke during one of the tests of the greeter apparatus as a whole. It proved difficult to mount a rectangular motor onto the inside of a sphere, which caused the rotor to rotate at an unnatural angle; this angle, coupled with the hot glue preventing the rotor from disengaging itself from this position, caused the motor to break.
Date of Upload: June 5, 2018
Jack's body (the skeleton) was constructed and adhered to the pedestal that will hold the box containing Jack's head. The box was also constructed that will house the scissor jack and Jack's head. The expected arrival date of Jack's suit was Friday, two days past the project deadline. As a result, the group had to compromise and purchase a black cloth to dress Jack's body.
Jack's body and pedestal |
//PIR_steppermotor_servomotor
//the time we give the sensor to calibrate (30 secs according to the datasheet)
int calibrationTime = 30;
//the time when the sensor outputs a low impulse
long unsigned int lowIn;
//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int pause = 5000;
boolean lockLow = true;
boolean takeLowTime;
int pirPin = 3; //the digital pin connected to the PIR sensor's output
int ledPin = 13;
//setup stepper vars
#include <Stepper.h>
//Stepper motor
#define step_pin 13
#define dir_pin 2
#define MS1 5
#define MS2 4
int dir;
int steps=1500;
//setup servo motor
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 20; // variable to store the servo position
/////////////////////////////
//SETUP
void setup(){
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(pirPin, LOW);
//stepper setup
pinMode(MS1,OUTPUT);
pinMode(MS2,OUTPUT);
pinMode(dir_pin,OUTPUT);
pinMode(step_pin,OUTPUT);
digitalWrite(MS1,LOW);
digitalWrite(MS2,LOW);
digitalWrite(dir_pin, HIGH); //LOW=CLOCKWISE
//servo setup
myservo.attach(9); // attaches the servo on pin 9 to the servo object
//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for(int i = 0; i < calibrationTime; i++){
Serial.print(".");
delay(1000);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
delay(50);
}
////////////////////////////
//LOOP
void loop(){
if(digitalRead(pirPin) == HIGH){
digitalWrite(ledPin, HIGH); //the led visualizes the sensors output pin state
if(lockLow){
//makes sure we wait for a transition to LOW before any further output is made:
lockLow = false;
Serial.println("---");
Serial.print("motion detected at ");
Serial.print(millis()/1000);
Serial.println(" sec");
delay(50);
//stepper rotate
while (steps>=0){
digitalWrite(step_pin,HIGH);
delay(5);
digitalWrite(step_pin,LOW);
delay(5);
steps--;
if (steps==1){
for (pos = 20; pos <= 60; pos += 2) {
myservo.write(pos);
delay(10);
}
for (pos = 60; pos >= 20; pos -= 2) {
myservo.write(pos);
delay(10);
}
for (pos = 0; pos <= 40; pos += 2) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
for (pos = 40; pos >= 0; pos -= 2) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
*The last seven lines listed repeat several times to form a manual loop
Fully operational system
Arduino board (blue rectangle) and circuit board (red rectangle) |
Closer look at circuit board component (not all wires shown) |
Stepper circuit |
Servo circuit |
PIR circuit |
Going into tomorrow's presentation, there are two main aspects of the current design with the potential to fail. The first part of the design that currently performs unreliably is the PIR sensor. This sensor is somewhat reliable in dark conditions, but in brightly lit rooms it struggles to detect when a person is passing in front of it. A toilet paper roll was taped to this sensor in an attempt to decrease the amount of environmental light that could interfere with the sensor, but it failed to make a significant difference.
The second unreliable part of the design is the servo motor, because it broke during one of the tests of the greeter apparatus as a whole. It proved difficult to mount a rectangular motor onto the inside of a sphere, which caused the rotor to rotate at an unnatural angle; this angle, coupled with the hot glue preventing the rotor from disengaging itself from this position, caused the motor to break.
Mostly operational system (servo motor breaks at end of sequence)
Date of Upload: June 5, 2018
Comments
Post a Comment