Added entirety of CAD files, Software and the translated documentation
This commit is contained in:
@ -0,0 +1,31 @@
|
||||
/*
|
||||
Knob
|
||||
Controlling a servo position using a potentiometer (variable resistor)
|
||||
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
|
||||
Adapted by Philip van Allen <philvanallen.com> for the VarSpeedServo.h library (October 2013)
|
||||
This example code is in the public domain
|
||||
|
||||
Moves a servo to a position, determined by a scaled value from an analog input, driven by a knob (potentiometer)
|
||||
Note that servos usually require more power than is available from the USB port - use an external power supply!
|
||||
*/
|
||||
|
||||
#include <VarSpeedServo.h>
|
||||
|
||||
VarSpeedServo myservo; // create servo object to control a servo
|
||||
|
||||
const int potPin = 0; // analog pin used to connect the potentiometer
|
||||
const int servoPin = 9; // the digital pin used for the servo
|
||||
|
||||
int val; // variable to read the value from the analog pin
|
||||
|
||||
|
||||
void setup() {
|
||||
myservo.attach(servoPin); // attaches the servo on pin 9 to the servo object
|
||||
}
|
||||
|
||||
void loop() {
|
||||
val = analogRead(potPin); // reads the value of the potentiometer (value between 0 and 1023)
|
||||
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value from 0 and 180)
|
||||
myservo.write(val); // sets the servo position according to the scaled value
|
||||
delay(15); // waits a bit before the next value is read and written
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
ServoSequence
|
||||
Reads an analog input, and plays different servo sequences depending on the analog value
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
#include <VarSpeedServo.h>
|
||||
|
||||
VarSpeedServo myservo1;
|
||||
|
||||
const int servoPin1 = 9; // the digital pin used for the servo
|
||||
|
||||
// sequences are defined as an array of points in the sequence
|
||||
// each point has a position from 0 - 180, and a speed to get to that position
|
||||
servoSequencePoint slow[] = {{100,20},{20,20},{60,50}}; // go to position 100 at speed of 20, position 20 speed 20, position 60, speed 50
|
||||
servoSequencePoint twitchy[] = {{0,255},{180,40},{90,127},{120,60}};
|
||||
|
||||
const int analogPin = A0;
|
||||
|
||||
// the setup routine runs once when you press reset:
|
||||
void setup() {
|
||||
myservo1.attach(servoPin1);
|
||||
}
|
||||
|
||||
// the loop routine runs over and over again forever:
|
||||
void loop() {
|
||||
// read the input on analog pin 0:
|
||||
int sensorValue = analogRead(analogPin);
|
||||
if (sensorValue > 200) {
|
||||
myservo1.sequencePlay(slow, 3); // play sequence "slowHalf" that has 3 positions, loop and start at first position
|
||||
} else {
|
||||
myservo1.sequencePlay(twitchy, 4, true, 2); // play sequence "twitchy", loop, start at third position
|
||||
}
|
||||
delay(2); // delay in between reads for analogin stability
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
Sweep
|
||||
by BARRAGAN <http://barraganstudio.com>
|
||||
Adapted by Philip van Allen <philvanallen.com> for the VarSpeedServo.h library (October 2013)
|
||||
This example code is in the public domain
|
||||
|
||||
Sweep a servo back and forth from 0-180 degrees, 180-0 degrees
|
||||
Uses the wait feature of the 2013 version of VarSpeedServo to stop the code until the servo finishes moving
|
||||
|
||||
Note that servos usually require more power than is available from the USB port - use an external power supply!
|
||||
*/
|
||||
|
||||
#include <VarSpeedServo.h>
|
||||
|
||||
VarSpeedServo myservo; // create servo object to control a servo
|
||||
// a maximum of eight servo objects can be created
|
||||
|
||||
const int servoPin = 9; // the digital pin used for the servo
|
||||
|
||||
void setup() {
|
||||
myservo.attach(servoPin); // attaches the servo on pin 9 to the servo object
|
||||
myservo.write(0,255,true); // set the intial position of the servo, as fast as possible, wait until done
|
||||
}
|
||||
|
||||
void loop() {
|
||||
myservo.write(180,255,true); // move the servo to 180, max speed, wait until done
|
||||
// write(degrees 0-180, speed 1-255, wait to complete true-false)
|
||||
myservo.write(0,30,true); // move the servo to 180, slow speed, wait until done
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
SweepTwoServos
|
||||
By Philip van Allen <philvanallen.com> for the VarSpeedServo.h library (October 2013)
|
||||
This example code is in the public domain
|
||||
|
||||
Sweep two servos from 0-180, 180-0 in unison
|
||||
Uses the wait feature of the 2013 version of VarSpeedServo to start the first servo moving in the background
|
||||
and immediately starting a second servo moving and waiting for the second one to finish.
|
||||
|
||||
Note that two servos will require more power than is available from the USB port - use an external power supply!
|
||||
*/
|
||||
|
||||
#include <VarSpeedServo.h>
|
||||
|
||||
VarSpeedServo myservo1; // create servo object to control a servo
|
||||
// a maximum of eight servo objects can be created
|
||||
VarSpeedServo myservo2;
|
||||
|
||||
const int servoPin1 = 9; // the digital pin used for the first servo
|
||||
const int servoPin2 = 10; // the digital pin used for the second servo
|
||||
|
||||
void setup() {
|
||||
myservo1.attach(servoPin1); // attaches the servo on pin 9 to the servo object
|
||||
myservo1.write(0,255,false); // set the intial position of the servo, as fast as possible, run in background
|
||||
myservo2.attach(servoPin2); // attaches the servo on pin 9 to the servo object
|
||||
myservo2.write(0,255,true); // set the intial position of the servo, as fast as possible, wait until done
|
||||
}
|
||||
|
||||
void loop() {
|
||||
myservo1.write(180,127,false); // move the servo to 180, fast speed, run background
|
||||
// write(degrees 0-180, speed 1-255, wait to complete true-false)
|
||||
myservo2.write(180,127,true); // move the servo to 180, fast speed, wait until done
|
||||
|
||||
myservo1.write(0,30,false); // move the servo to 180, slow speed, run in background
|
||||
myservo2.write(0,30,true); // move the servo to 180, slow speed, wait until done
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
#include <VarSpeedServo.h>
|
||||
|
||||
// create servo object to control a servo
|
||||
VarSpeedServo myservo1;
|
||||
VarSpeedServo myservo2;
|
||||
|
||||
void setup() {
|
||||
|
||||
// initialize serial:
|
||||
//Serial.begin(9600);
|
||||
|
||||
myservo1.attach(9);
|
||||
myservo2.attach(8);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
int LEF = 0;
|
||||
int RIG = 180;
|
||||
|
||||
int SPEED1 = 160;
|
||||
int SPEED2 = 100;
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
|
||||
myservo1.write(LEF, SPEED1);
|
||||
myservo2.write(LEF, SPEED2);
|
||||
myservo1.wait();
|
||||
myservo2.wait();
|
||||
|
||||
myservo1.write(RIG, SPEED1);
|
||||
myservo1.wait();
|
||||
|
||||
myservo1.write(LEF, SPEED1);
|
||||
myservo2.write(RIG, SPEED2);
|
||||
myservo1.wait();
|
||||
myservo2.wait();
|
||||
|
||||
myservo1.write(RIG, SPEED1);
|
||||
myservo1.wait();
|
||||
|
||||
}
|
||||
|
||||
///*
|
||||
delay(3000);
|
||||
myservo1.detach();
|
||||
myservo2.detach();
|
||||
// */
|
||||
}
|
||||
|
Reference in New Issue
Block a user