Lab7 - Crawler

Submitted by katehsiao on Tue, 03/19/2013 - 17:36

 

Description

In this simple crawler, I used a piece of cardboard to crawl and added an earplug to increase the friction. The box will be lifted when the cardboard is swinging to one side. I also added part of the earplug under the box preventing the box going backward when the cardboard is swinging back.
 
 

Components Used

1- Arduino Uno
1- Breadboard
1- Servo Motor
1- cardboard
1- earplug
1- box
 
 

Code

 
/*
 * Lab 7 Crawler
 * 
 * Created 19 Mar 2013
 * Kate Hsiao
 */
 
int servoPin = 7;
 
long lastPulse = 0; 
int refreshTime = 20; 
int flag = 1;
int interval = 500;
long lastChange = 0;
 
void setup() {
  pinMode(servoPin, OUTPUT);  
  Serial.begin(9600);       
}
 
void loop() {
  
  if (millis() - lastChange >= 1000) {
    interval = (interval==500) ? 1375 : 500;
    lastChange = millis();
  }
  updateServo();  
 
}
 
 
void updateServo() {
  
  if (millis() - lastPulse >= refreshTime) {
    digitalWrite(servoPin, HIGH);  
    delayMicroseconds(interval); 
    digitalWrite(servoPin, LOW);  
    lastPulse = millis();         
  }
  
}
 
 
IMG_3901.jpg
IMG_3903.JPG
0
Your rating: None
Drupal theme by Kiwi Themes.