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