Tuesday, December 9, 2014

The Reveal!!!

Today we met to assemble the crane as a whole and run the code for the motors.  The assembly went well, as is evident in the pictures below


The problems ((DUN! DUN! DUNNNN!)
In assembling the crane, we came across two somewhat minor problems and also developed potential solutions for each problem.
  1. When combining the code for both motors, the servo motor keeps running its code and also the DC Motor code.
    1. The Solution:  We will use two arduinos and upload one code onto one of them, using an external power supply to power that motor.  This way there is no code interference.
  2.  The DC motor does not provide enough torque to lift the tiny fishing weight we are using for the crane.  
    1. The Solution:  We ordered a stepper motor, so we will pick that up from the lab and see if it provides the necessary torque required to lift the weight. 
 The Code for The DC Motor
void setup() {
 

  pinMode(12, OUTPUT);
  pinMode(9, OUTPUT);
 
}

void loop(){
 

  digitalWrite(12, HIGH);
  digitalWrite(9, LOW);  
  analogWrite(3, 100);  
 
  delay(1000);
 
  digitalWrite(9, HIGH);

  delay(1000);
 

  digitalWrite(12, LOW);
  digitalWrite(9, LOW);  
  analogWrite(3, 100);  
 
  delay(1000);
 
  digitalWrite(9, HIGH);
 
  delay(1000);
 
}
 
The Code for the Servo Motor

#include <Servo.h>

Servo myservo; 

int pos = 0;

void setup()
{
  myservo.attach(9); 
}


void loop()
{
  for(pos = 0; pos < 90; pos += 1) 
  {                            
    myservo.write(pos);            
    delay(15);                     
  }
  for(pos = 90; pos>=1; pos-=0)    
  {                              
    myservo.write(pos);             
    delay(1000);
  for(pos = 90; pos>=1; pos-=1)   
  {                              
    myservo.write(pos);           
    delay(15);                    
  }
  for(pos = 0; pos<90; pos-=0)  
  {                              
    myservo.write(pos);             
    delay(1000);                      
  }
  }
}
 


The Next Meet-up
We will meet on Thursday at 1:00PM to attempt to use the Stepper Motor as well as put the finishing touches on our crane.  If the stepper does not provide the necessary torque, we official change our name to TEAM MILEY CYRUS WRECKING BALL 


No comments:

Post a Comment