Announcements

November 24, 2007
Reading for November 27th, are now posted. Enjoy!

October 2, 2007
To upload your thoughtless acts, create a new assignment page like any other lab. You'll see "Thoughtless Acts" listed as one of the assignment options.

May 24, 2008
This site has been archived and is no longer editable. Stay tuned for the next version, coming in the fall!


Lab 7:Robot Pet

Project Members: 
Hsin-Hsien Chiu

Description: Robot Pet

Given that living in the metropolis brings tremendous pressure, the intention of this project is to make a “Robot Pet” to enrich our lives. The first phase is to design the crawler. Using some components from hardware and LEGO, I try to make a robot-like crawler able to move both forth and back with two servo motors. The second phrase is to make the “Robot Pet” serve the master, e.g. giving a cruet or a cup of water. This design could include two users. When the 1st user puts an object on the robot pet, the FSR will make the robot pet be launched and keep on moving forward to the 2nd user until the object has been taken off; afterward, the robot pet will move back to the original position. However, the code in the second phrase hasn’t be overcome yet. I simply make a video to express the idea.    

Components:

Servo motor x 2

FSR x 1  

Arduino board x 1

Hardware(screws/ nuts/ steel wires)

LEGO components x 2

Transparent container x 1

cruet x 1 

Bubble paper  

 

Arduino Code:

/*
 * Two servos with two potentiometer control
 * Theory and Practice of Tangible User Interfaces
 * October 11 2007
 *
 */

int servoPin1 = 7;      // Control pin for servo motor 1
int servoPin2 = 8;      // Control pin for servo motor 2
int potPin1   = 0;      // select the input pin for the potentiometer 1
int potPin2   = 1;      // select the input pin for the potentiometer 2

int pulseWidth1 = 0;    // Amount to pulse the servo 1
int pulseWidth2 = 0;    // Amount to pulse the servo 2
long lastPulse1 = 0;    // the time in millisecs of the last pulse of servo 1
long lastPulse2 = 0;    // the time in millisecs of the last pulse of servo 2
int val_1;              // variable used to store data from potentiometer 1
int val_2;              // variable used to store data from potentiometer 2

int refreshTime = 20;   // the time in millisecs needed in between pulses
int minPulse = 500;    // minimum pulse width

void setup() {
  pinMode(servoPin1, OUTPUT);  // Set servo pin 1 as an output pin
  pinMode(servoPin2, OUTPUT);  // Set servo pin 2 as an output pin
  pulseWidth1 = minPulse;      // Set the motor position to the minimum
  pulseWidth2 = minPulse;      // Set the motor position to the minimum
  Serial.begin(9600);          // connect to the serial port
  Serial.println("Two servos with two potentiometers ready");
}

void loop() {
  val_1 = analogRead(potPin1);    // read the value from the sensor 1, between 0 - 1024
  val_2 = analogRead(potPin2);    // read the value from the sensor 2, between 0 - 1024
    
  if (val_1 > 0 && val_1 <= 999 ) {
    pulseWidth1 = val_1*2 + minPulse;  // convert angle to microseconds
  }
  updateServo1();   // update servo 1 position

  if (val_2 > 0 && val_2 <= 999 ) {
    pulseWidth2 = val_2*2 + minPulse;  // convert angle to microseconds
  }
  updateServo2();   // update servo 2 position
}

void updateServo1() {
  if (millis() - lastPulse1 >= refreshTime) {
    digitalWrite(servoPin1, HIGH); 
    delayMicroseconds(pulseWidth1);  
    digitalWrite(servoPin1, LOW);   
    lastPulse1 = millis();          
  }
}

void updateServo2() {
  if (millis() - lastPulse2 >= refreshTime) {
    digitalWrite(servoPin2, HIGH);  
    delayMicroseconds(pulseWidth2);  
    digitalWrite(servoPin2, LOW);   
    lastPulse2 = millis(); 
  }
}
Movies:
http://www.youtube.com/watch?v=s77WQ5Y42IQ
http://www.youtube.com/watch?v=F8rHkwxRnYI
 
 
Images:
http://photo.xuite.net/berkeleychiu/2067822/4.jpg
http://photo.xuite.net/berkeleychiu/2067822/3.jpg
http://photo.xuite.net/berkeleychiu/2067822/2.jpg
http://photo.xuite.net/berkeleychiu/2067822/1.jpg
http://photo.xuite.net/berkeleychiu/2067822/5.jpg
http://photo.xuite.net/berkeleychiu/2067822/6.jpg

 
 

AttachmentSize
PA180019.JPG79.4 KB
PA180018.JPG74.56 KB
PA180024.JPG38.39 KB
PA180016.JPG75.27 KB
PA180017.JPG65.43 KB
PA180021.JPG45.13 KB

Powered by Drupal - Design by Artinet