Monday, April 2, 2012

Media Controller Project






Media Controller Project - By Anthony Coppola and Mike Johnston

Controller guided Servo Tilt Maze

What We Did : For our project, myself and Mike embarked to create a maze game that would replicate the angle of a small controller using servo's underneath the maze itself.  We would connect tilt sensors to the inside of the controller, and it would then send the information to the arduino to tell the servo's which direction to go.  The servo's would act as a balancing mechanism as well as a tilt controller for the maze.

How we did it : We used a small, light wooden box from Micheal's, the arduino, a breadboard, some tilt sensors from Adafruit, rubber balls and a PSP tin from a party store, rubber tubing, a steel rod, and hanger nails from Ewing Hardware, and some wood from Home dept.  We used the bottom portion of the box as housing, and the cover as the actual maze, we connected the servo's to the rod , and then that to the rubber ball which acted as a ball and socket joint for the maze.  We then attached the tilt sensors to the PSP tin, connected that to the arduino, connected the arduino to the servos, and with the generous help of the fantastic people in class including our teacher Avani, we were able to write the code to get the sensors "talk" to the servo's.

What we learned : All in all, it was a fun project conceptually, but it was very challenging to us.  We unfortunately did not get it to work in time for the presentation, but we learned a ton about servo's and prototyping.  It was an enjoyable project with a lot of potential and I know that with more time, some more resources and energy, we could have submitted this to the art gallery.



Here is the code from our project

//Tilt maze by Ant C and Mike J
#include <Servo.h>

int tiltPinX = 7;                 // Gravity switch connected to pin 6
int tiltPinY = 6;              // Other gravity switch connected to pin 7

int posX = 0;
int posY = 0;

Servo servoX;
Servo servoY;

int valX = 0;
int valY = 0;

int count = 0;

void setup()
{
  servoX.attach(10);  //attaches servo 1 to digital pin 10
  servoY.attach(11);  //attaches servo 2 to digital pin 11
  count++;
 
  pinMode(tiltPinX, INPUT);  //intialize tilt sensor 1
  pinMode(tiltPinY, INPUT);  //intialize tilt sensor 2
 
 // Serial.begin(9600); //sets up serial monitor for 9600 baud
}

void loop()
{
  valX = digitalRead(tiltPinX);  //reads tilt sensor 1
  valY = digitalRead(tiltPinY); //reads tilt sensor 2
 
//  Serial. println (" Value of tilt sensor X: " + valX); //displays tilt sensor X in serial monitor
//  Serial. println(" Value of tilt sensor Y: " + valY);  //displays tilt sensor Y in serial monitor
 
  if(valX == LOW)
  {
    posX = 0;
    servoX.write(-15);
    delay(15);
    count = 0;
  } else
  {
    count = 0;
   for(posX = 0; posX <45; posX++)
    {
     servoX.write(15);
     delay(15);
    }
  }
 
  if(valY == LOW)
  {
    posY = 0;
    servoY.write(-15);
    delay(15);
    count = 0;
  } else
  {
    count = 0;
    for(posY = 0; posY <45; posY++)
    {
     servoY.write(15);
     delay(15);
    }
  }
 
  if(count == 8000)
  {
    servoX.write(0);
    servoY.write(0);
  }
 
}









No comments:

Post a Comment