Monday, March 11, 2013

Bicyclist 1: The Project Menace


Alright, this is my first post on my impending midterm project. What I've decided to go with is my bicyclist idea. The project is a moving sculpture of a man biking forward, but when you hit the 'terror button' he becomes frightens and starts biking backwards even faster. Basic design work for the cyclist:



Alright, so I know what my cyclist is going to look like (and generally where his legs must bend to cycle). I also decided to revamp what kind of bike he'll be using. Next step: start that code!

...

...

Got it! Here's the code (with the tentative second servo included):
#include <Servo.h> 

Servo myservo; // creating myservo object
Servo myservo2;

int buttonPin = 3; // set button pin
int buttonState = 0; // set buttonState 

void setup()
{
myservo.attach(0); // attach the 13 pin to servo
myservo.attach(13);

pinMode(buttonPin, INPUT); // set button to input
}


void loop()
  buttonState = digitalRead(buttonPin); // read and save to the variable "buttonState" the actual state of button 

if (buttonState == LOW)
{
myservo.write(80); 
myservo2.write(0);
}

else {
myservo.write(179);
myservo2.write(180);
}

}

And a video of the pedal motor in action:


No comments:

Post a Comment