User login

Powered by Drupal, an open source content management system

Theory and Practice of Tangible User Interfaces

Lab 07: Tricycle Cork Bot & Quadra Cork Bot

Submitted by andy on Sun, 10/19/2008 - 22:52

Assignment: Servo Motor: Actuation Assignment 2

Collaborators:

Description

Tricycle Cork Bot is a 3-legged spider controlled by a servo. I bent a paper clip into a u-shape, and inserted it into the top of the servo head. The two ends then point towards the ground, and are tipped with pieces of sawed off cork. The third leg is made up of a paper clip and aileron linkage, and is taped to the bottom of the servo.

Quadra Cork Bot is 4-legged walker controlled by two servos that operate in parallel. Twist the potentiometer back and forth to make QCB's legs walk, pushing it forward. I essentially doubled the 3-legged spider design for QCB, and also removed the tail-dragging paper clip and aileron linkage setup.

Jump to Quadra Cork Bot

 

Components (Tricycle Cork Bot)

  • aileron linkage
  • (2) paper clips
  • (2) cork slices
  • Arduino
  • solderless breakboard
  • misc wires
  • duct tape
  • (1) servo

 

Arduino Code (Tricycle Cork Bot)

/*
* Servo Control Serial
* modified for TUI October 2007
* Servo Serial Better
* -------------------
*
* Created 18 October 2006
* copyleft 2006 Tod E. Kurt <tod@todbot.com>
* http://todbot.com/
*
* adapted from "http://itp.nyu.edu/physcomp/Labs/Servo"
*/

int servoPin = 7; // Control pin for servo motor

int pulseWidth = 0; // Amount to pulse the servo
long lastPulse = 0; // the time in millisecs of the last pulse
int refreshTime = 20; // the time in millisecs needed in between pulses
int val; // variable used to store data from serial port

int minPulse = 500; // minimum pulse width
int maxPulse = 2250; // maximum pulse width

void setup() {
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
pulseWidth = minPulse; // Set the motor position to the minimum
Serial.begin(9600); // connect to the serial port
Serial.println("Servo control program ready");
}

void loop() {
val = Serial.read(); // read the serial port
if (val >= '1' && val <= '9' ) {
val = val - '0'; // convert val from character variable to number variable
val = val - 1; // make val go from 0-8
pulseWidth = (val * (maxPulse-minPulse) / 8) + minPulse; // convert val to microseconds
Serial.print("Moving servo to position ");
Serial.println(pulseWidth,DEC);
}
updateServo(); // update servo position
}

// called every loop().
// uses global variables servoPi, pulsewidth, lastPulse, & refreshTime
void updateServo() {
// pulse the servo again if rhe refresh time (20 ms) have passed:
if (millis() - lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
delayMicroseconds(pulseWidth); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
lastPulse = millis(); // save the time of the last pulse
}
}

Photographs (Tricycle Cork Bot)

TUI Lab: TriCorkBot - Front 3/4

 

TUI Lab: TriCorkBot - Rear 3/4

 

TUI Lab: TriCorkBot + Arduino

 

Video (Tricycle Cork Bot)





 

 

Components (Quadra Cork Bot)

  • (2) paper clips
  • (4) cork slices
  • Arduino
  • solderless breakboard
  • misc wires
  • duct tape
  • (2) servos
  • (1) potentiometer

Arduino Code (Quadra Cork Bot)

/*
* Servo Control Serial -
* also modified by Andy for TUI Fall 2008
* modified for TUI October 2007
* Servo Serial Better
* -------------------
*
* Created 18 October 2006
* copyleft 2006 Tod E. Kurt <tod@todbot.com>
* http://todbot.com/
*
* adapted from "http://itp.nyu.edu/physcomp/Labs/Servo"
*/

int potPin = 2;
int servoPin = 7; // Control pin for servo motor
int servoPinRear = 8;


int pulseWidth = 0; // Amount to pulse the servo
long lastPulse = 0; // the time in millisecs of the last pulse
int refreshTime = 20; // the time in millisecs needed in between pulses
int val; // variable used to store data from serial port
int val2;

int minPulse = 500; // minimum pulse width
int maxPulse = 2250; // maximum pulse width

void setup() {
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
pinMode(servoPinRear, OUTPUT);
pulseWidth = minPulse; // Set the motor position to the minimum
Serial.begin(9600); // connect to the serial port
Serial.println("Servo control program ready");
}

void loop() {

val2 = analogRead(potPin);
Serial.println(val2);
//val = Serial.read(); // read the serial port
//if (val >= '1' && val <= '9' ) {
// val = val - '0'; // convert val from character variable to number variable
//val = val - 1; // make val go from 0-8
// pulseWidth = (val * (maxPulse-minPulse) / 8) + minPulse; // convert val to microseconds
// Serial.print("Moving servo to position");
// Serial.println(pulseWidth,DEC);
// }

if (val2 <= 100) {
updateServoCenter();
}

if (val2 > 100 && val2 <= 600) {
updateServoLeft(); // update servo position
}

if (val2 > 600) {
updateServoRight(); // update servo position
}
}

void updateServoCenter() {
if (millis() - lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
digitalWrite(servoPinRear, HIGH);
delayMicroseconds(1375); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
digitalWrite(servoPinRear, LOW);
lastPulse = millis();
}
}

void updateServoLeft() {
if (millis() - lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
digitalWrite(servoPinRear, HIGH);
delayMicroseconds(1156); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
digitalWrite(servoPinRear, LOW);
lastPulse = millis();
}
}


void updateServoRight() {
if (millis() - lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
digitalWrite(servoPinRear, HIGH);
delayMicroseconds(1593); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
digitalWrite(servoPinRear, LOW);
lastPulse = millis();
}
}



Photographs (Quadra Cork Bot)

TUI Lab: Quadra Cork Bot - Front 3/4

TUI Lab: Quadra Cork Bot - Side

TUI Lab: Quadra Cork Bot + Arduino

Video (Quadra Cork Bot)