Making Things Interactive

February 19, 2008

Solenoid/Servo Target Shooter

Filed under: 6: More Motion,Assignments,Christopher Bridgman — cbridgma @ 2:00 am

So, for this assignment, i wanted to create a target shooting device out of the solenoid so it would hit a target on the servo motor. i guess this was my interpretation of making the components do something. So here it finally is. This was done by using a simple tilt switch to fire the solenoid to try and hit the servo motor which operated off a simple time delay. However, after hooking all of this stuff up together, the sensor responded very slowly and im not sure why. It made it hard to actually hit the target. But anyways, here is the video.


int statusPin = 13;                // LED connected to digital pin 13
int switchPin = 6;                 // Gravity switch connected to pin 6
int servoPin = 11;                 //servo connected to pin 11
int solenoid = 2;                 //solenoid connected to pin 2
int val;

void setup()                    // run once, when the sketch starts
{
  pinMode(statusPin, OUTPUT);      // sets the digital pin as output
  pinMode(servoPin, OUTPUT);       //sets the analog pin as output
  pinMode(solenoid, OUTPUT);       //sets the digital pin as output
  pinMode(switchPin, INPUT);       //sets the digital pin as input
  Serial.begin(9600); 
}

void loop()                     // run over and over again
{
  val = digitalRead(switchPin);

  Serial.print("Value: ");
  Serial.println(val);   

  analogWrite(servoPin,16); 
  delay(1000);
  analogWrite(servoPin,96);
  delay(1000);
 
  if (val == 1)
  {
      digitalWrite(solenoid,HIGH);
      digitalWrite(statusPin,HIGH);
    }
  if (val == 0)
  {
    digitalWrite(solenoid,LOW);
    digitalWrite(statusPin, LOW);
  }
}
Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: