The Crashed Swimming Plane

Description:

This looks like a crashed plane trying to swim. I attached two hands of the servo motor attachment to the two wings of the plane which makes the wings go forward alternately. I used the arduino sweep code for this assignment

Components Used:

1 Arduino
1 Servomotor
Cardboard pieces
Screws
Dampening rubbers

Code:


/* Sweep
by BARRAGAN
This example code is in the public domain.

modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/

#include

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}

img_20161018_205221

img_20161018_205246

A Colorful Creature of the Future

This lab presented unique challenges that I hadn’t met in earlier assignments. Because of the servo motor’s limited range of movement, I had to find a way to distribute weight in such a way that would encourage the motor to move forward. I researched how bugs and other animals move and the only animals that move in side-to-side fashions (like the servo motor) are sea creatures. That wouldn’t work for this project. I ultimately came up with a creature of the future whose feet are made of tack glides for furniture, a paper towel roll, a chip clip, and a plastic beam and hairclip to help distribute the weight. The creature of the future moves by turning the potentiometer left and right.

Components:

  1. 1 Arduino board
  2. 1 Breadboard
  3. Jumper wires
  4. 1 potentiometer
  5. 1 servo motor
  6. 1 USB cable
  7. 2 tack glides for furniture
  8. several hairclips
  9. 1 chip clip
  10. 1 paper towel roll
  11. Duct tape
  12. small plastic beam
  13. Pipe cleaners to create a Quidditch hoop to tie this back to Harry Potter.

Code:

/*
 * Servo with Potentiometer control
 * Theory and Practice of Tangible User Interfaces
 * October 11 2007
 */

int servoPin = 7; // Control pin for servo motor
int potPin = 0; // select the input pin for the potentiometer

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 potentiometer

int minPulse = 500; // minimum 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_serial_better ready");
}

void loop() {
 val = analogRead(potPin); // read the value from the sensor, between 0 - 1024
 
 if (val > 0 && val <= 999 ) {
 pulseWidth = val*2 + minPulse; // convert angle to microseconds
 
 Serial.print("moving servo to ");
 Serial.println(pulseWidth,DEC);
 
 }
 updateServo(); // update servo position
}

// called every loop(). 
void updateServo() {
 // pulse the servo again if the refresh time (20 ms) has 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
 }
}

 

Lab07: Cutlery Crawling

Description:

A few choices that I made:
– I used a bundle of knives to counterbalance the weight of the fork and the motor. At first I was worried that they would make it too heavy altogether, but it ended up being okay.
– I used tape to fix the joints of the frame thingy (which was just a novelty item that my roommate brought home from his IBM museum visit).
– I chose a fork as an arm, first because I thought that the pointier side of the fork would stick in the carpet and effectively move it, while the other side (with the tine points facing up) would slide along the floor. Instead, when the tines were facing down, they kind of skipped along the floor and didn’t effective move the crawler, so it ended up crawling in the other direction.

I left the code unchanged from the example, and just used the pot to manually control it.

 

Components Used:

  • 1 Arduino
  • 1 Servomotor
  • 1 Breadboard
  • 1 pot
  • 2 pipe cleaners (to lash the fork to the motor)
  • lots of masking tape
  • 4 knives
  • 1 fork

Code:

/*
 * 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
 }
}

lab07pic

 

VIDEO: lab07

Little google eye crawler!

Description:

This week Molly and I teamed up to have a crawler for the TUI crawler challenge! We used 2 servomotors and a large battery pack, and some earplugs for grip on the carpet. It was difficult to stabilize the body – we tried markers, triangle shaped highlighters, and ended up using the servo box with clips to raise it.

img_1683

 

Components

  • 1x Bread board
  • 1x Arduino
  • 1x servomotor
  • 1x box
  • 2x paperclip
  • 1x battery pack
  • 4x ear plug
  • 10x+ rubber bands and hair ties

Code


/*
* Code modified from this code: http://www.robotoid.com/appnotes/arduino-operating-two-servos.html
*/
#include
Servo servoLeft; // Define left servo
Servo servoRight; // Define right servo
int pos7 = 0;
int pos8 = 0;
void setup() {
servoLeft.attach(8); // Set left servo to digital pin 8
servoRight.attach(7); // Set right servo to digital pin 7
servoLeft.write(0);
servoRight.write(0);
}
void loop() { // Loop through motion tests
moveR(); // Example: move forward
moveL();
// moveR();
// moveL();
// moveR();
// moveL();
}
// Motion routines for forward, reverse, turns, and stop
void moveR() {
//servoLeft.write(0);
//servoRight.write(130);
for (pos7 = 0; pos7 <= 120; pos7 += 5) { // goes from 0 degrees to 180 degrees // in steps of 1 degree servoRight.write(pos7); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos7 = 120; pos7 >= 0; pos7 -= 10) { // goes from 180 degrees to 0 degrees
servoRight.write(pos7); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
void moveL() {
//servoLeft.write(130);
//servoRight.write(0);
for (pos8 = 0; pos8 <= 120; pos8 += 5) { // goes from 0 degrees to 180 degrees // in steps of 1 degree servoLeft.write(pos8); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos8 = 120; pos8 >= 0; pos8 -= 10) { // goes from 180 degrees to 0 degrees
servoLeft.write(pos8); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}

 

 

Lab07: Crimson Crawler

Description:

I had so much fun assembling this crawler, thinking about the mechanics of a one-legged crawler, and how weight would need to be distributed to get it to move in a linear direction. While hardwood floor doesn’t allow for enough friction between it and the tips of the paperclips, the knit of my scarf produced similar (but slightly better) results. I discovered that my crawler crawls best on a surface with some teeth to it, such as the cover of one of my sketchbooks. Through experimentation I discovered that in order to get it to walk straighter, I needed to reprogram the arduino such that it didn’t have the servomotor have one single sweeping pattern.

Components Used:

  • 1 Arduino
  • 1 Servomotor
  • 1 Breadboard
  • 1 pot (but unused in the sketch below)
  • 1 large paperclip, 1 medium paperclip
  • 1 Futaba servomotor box
  • 1 X-factor nail polish bottle
  • electrical tape

Code:

/*
 * 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"
 */
#include <Servo.h>

Servo myservo; // create servo object to control a servo
int servoPin = 7; // Control pin for servo motor

int pos = 0; // variable used to store data from serial port

int minPulse = 0; // minimum pulse width
int maxPulse = 100; // maximum pulse width

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

void loop() {
 for (pos = minPulse; pos <= maxPulse; pos += 1) { // goes from 0 degrees to 180 degrees
 // in steps of 1 degree
 myservo.write(pos); // tell servo to go to position in variable 'pos'
 delay(7); // waits 7ms for the servo to reach the position
 }
 for (pos = maxPulse; pos >= minPulse; pos -= 1) { // goes from 180 degrees to 0 degrees
 myservo.write(pos); // tell servo to go to position in variable 'pos'
 delay(5); // waits 5ms for the servo to reach the position
 }
}



AND ALSO

/*
 * 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"
 */
#include <Servo.h>

Servo myservo; // create servo object to control a servo
int servoPin = 7; // Control pin for servo motor

int pos = 0; // variable used to store data from serial port

int minPulse = 0; // minimum pulse width
int maxPulse = 115; // maximum pulse width
int correction = 55;
int count = 0;

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

void loop() {
 for (count = 0; count <= 2; count +=1) {
 for (pos = correction; pos <= maxPulse; pos += 1) { // goes from 0 degrees to 180 degrees
 // in steps of 1 degree
 myservo.write(pos); // tell servo to go to position in variable 'pos'
 delay(7); // waits 7ms for the servo to reach the position
 }
 for (pos = maxPulse; pos >= correction; pos -= 1) { // goes from 180 degrees to 0 degrees
 myservo.write(pos); // tell servo to go to position in variable 'pos'
 delay(5); // waits 5ms for the servo to reach the position
 }
}
 for (count = 0; count <= 7; count +=1) {
 for (pos = minPulse; pos <= correction; pos += 1) { // goes from 0 degrees to 180 degrees
 // in steps of 1 degree
 myservo.write(pos); // tell servo to go to position in variable 'pos'
 delay(7); // waits 7ms for the servo to reach the position
 }
 for (pos = correction; pos >= minPulse; pos -= 1) { // goes from 180 degrees to 0 degrees
 myservo.write(pos); // tell servo to go to position in variable 'pos'
 delay(5); // waits 5ms for the servo to reach the position
 }
}


}




img_6347-mov img_6346-mov

Baby Steps

Description
My servo crawls with the help of a putty foot. The ball of its foot propels it forward when I rapidly rotate the pot by a small angle. The putty holds the “leg” together but also does not constrict the range of motion. It can only be rotated by a small angle only because it won’t otherwise it will go backwards.

Materials
Drill, Putty, Metal Hex, Tape, Toothpick
Clothespin
Servo, Servo Container, Potentiometer
Breadboard, Arduino, Jumper Cables

Code


/*
* Servo with Potentiometer control
* Theory and Practice of Tangible User Interfaces
* October 11 2007
*/

int servoPin = 7; // Control pin for servo motor
int potPin = 0; // select the input pin for the potentiometer

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 potentiometer

int minPulse = 500; // minimum 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_serial_better ready");
}

void loop() {
val = analogRead(potPin); // read the value from the sensor, between 0 - 1024

if (val > 0 && val <= 999 ) { pulseWidth = val*2 + minPulse; // convert angle to microseconds Serial.print("moving servo to "); Serial.println(pulseWidth,DEC); } updateServo(); // update servo position } // called every loop(). void updateServo() { // pulse the servo again if the refresh time (20 ms) has 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
}
}



Crawler (in circles) bot

Description

So my bot crawls, though mainly in circles (I believe the legs aren’t quite even). I tried to model my bot after knees, which are rigid in one direction (providing push) but bend in the other direction (to avoid undoing forward motion). I used binder clips to stabilize the bot’s base (the servo box) and prop the servo motor at a helpful angle.

Components

  • Arduino UNO
  • Servo motor
  • hookup wires
  • binder clips (1 very large, 1 small)
  • cardboard, popsicle sticks, wood glue, tape, pipecleaners

Code

/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.

modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/

#include ;

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(7); // attaches the servo on pin 9 to the servo object
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(4); // waits 15ms for the servo to reach the position
}
delay(200);
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(4); // waits 15ms for the servo to reach the position
}
delay(200);
}

Images/Video

knees   overview-shot  prop-detailcrawler-bot-video

Meet Bruce

This weekend, Andrea and I teamed up to create a little robot named Bruce.  We were able to get him to move forward (albeit in a somewhat circular pattern) by altering the starting and ending servo motor angles. We also had to compensate for the second servo motor being in a reverse position from the first. We modified the code by adding the second servo, such that for when one’s angle was 70 for example, the second would be 180-70.

Photo of Bruce

Watch Bruce go!


components

  • 2 servo motors
  • a box lid
  • 10 bamboo sticks
  • 3 furniture pads
  • 1 lobster mascot (named Bruce)
  • 3 plastic spoons
  • 1 ball of putty
  • A lot of electrical tape
  • 1 9v battery + connecter
  • 1 arduino
  • 1 breadboard
  • several connecting wires

code

/* Sweep

 by BARRAGAN <http://barraganstudio.com> 

 This example code is in the public domain.




 modified 8 Nov 2013

 by Scott Fitzgerald

 http://arduino.cc/en/Tutorial/Sweep

*/ 




#include <Servo.h> 

 

Servo myservo;

Servo myservo1;// create servo object to control a servo 

                // twelve servo objects can be created on most boards

 

int pos = 0;    // variable to store the servo position 

int potPin = A0;

 

void setup() 

{ 

  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 

  myservo1.attach(10);

} 

 

void loop() 

{ 

  for(pos = 70; pos <= 180; pos += 1) // goes from 70 degrees to 180 degrees 

  {                                  // in steps of 1 degree 

    myservo.write(pos); 

    myservo1.write(230 - pos);

    Serial.print(-pos);    // tell servo to go to position in variable 'pos' 

    delay(7);    // waits 15ms for the servo to reach the position 

  } 

  for(pos = 180; pos>=70; pos-=1)     // goes from 180 degrees to 70 degrees 

  {                                

    myservo.write(pos); 

    myservo1.write(230 - pos);    // tell servo to go to position in variable 'pos' 

    delay(7);                       // waits 15ms for the servo to reach the position 

  } 

}