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!


Baby crawler

Project Members: 
Anirban Sen

For this project, I wracked my brain and tried to come up with a crawler design that was derivative of the one that was in the class handout. After several attempts with that alignment (including taping the servo to the breadboard and attempting to make the entire assembly crawl), I finally decided to take another approach. I set the servo motor on the table with the fan facing downwards and attempted to make it crawl. I attained the best success with this alignment, so I stayed with this. I used pipe cleaner to stabilize the motor and provide a bit of "sideways wobble" for traction. The overall effect of the crawler is that it resembles a baby attempting to crawl.


Components:

Arduino Microprocessor
Breadboard
1 potentiometer
Servo motor
Connecting wires

Source Code:

int servoPin = 7;     // Control pin for servo motor
int minPulse = 500;   // Minimum servo position
int maxPulse = 2500;  // Maximum servo position
int pulse = 0;        // Amount to pulse the servo

long lastPulse = 0;    // the time in milliseconds of the last pulse
int refreshTime = 20; // the time needed in between pulses

int analogValue = 0;  // the value returned from the analog sensor
int analogPin = 0;    // the analog pin that the sensor's on

void setup() {
  pinMode(servoPin, OUTPUT);  // Set servo pin as an output pin
  pulse = minPulse;           // Set the motor position value to the minimum
  Serial.begin(9600);
}

void loop() {
  analogValue = analogRead(analogPin);      // read the analog input
  pulse = (analogValue * 19  ) / 10 + minPulse;    // convert the analog value
                                            // to a range between minPulse
                                            // and maxPulse.

  // pulse the servo again if rhe refresh time (20 ms) have passed:
  if (millis() - lastPulse >= refreshTime) {
    digitalWrite(servoPin, HIGH);   // Turn the motor on
    delayMicroseconds(pulse);       // Length of the pulse sets the motor position
    digitalWrite(servoPin, LOW);    // Turn the motor off
    lastPulse = millis();           // save the time of the last pulse
  }
}


AttachmentSize
IMG_2033.JPG777.27 KB

Powered by Drupal - Design by Artinet