Acrob006: Rozdiel medzi revíziami
Zo stránky SensorWiki
Bez shrnutí editace |
Bez shrnutí editace |
||
Riadok 1: | Riadok 1: | ||
[[Acrob005|< Previous]] | [[Acrob|Home]] | [[Acrob007|Next >]] | [[Acrob005|< Previous]] | [[Acrob|Home]] | [[Acrob007|Next >]] | ||
== Basic movements. Finally! == | == '''Basic movements. Finally!''' == | ||
Riadok 66: | Riadok 66: | ||
You may notice that Your motors not stop after the last command. | |||
You can either calibrate sensors using the screwdriver and small trimer inside the motor which is accessible through small opening in the side of the motor, or You can simply switch off the motor using the detach method | |||
LeftServo.detach(); | |||
RightServo.detach(); | |||
[[Acrob005|< Previous]] | [[Acrob|Home]] | [[Acrob007|Next >]] | [[Acrob005|< Previous]] | [[Acrob|Home]] | [[Acrob007|Next >]] |
Verzia z 12:16, 12. jún 2010
< Previous | Home | Next >
Basic movements. Finally!
Robot používa dva modifikované servomotory. Majú trojvodičové pripojenie, dva vodiče slúžia na napájanie, tretí je riadiaci signál. Rýchlosť a smer otáčania sa riadia šírkou impulzu. Pôvodne slúžil na nastavenie polohy v rozsahu 0-180 stupňov. Po úprave signál pre 90 st. motorček zastaví, 180 roztočí max. rýchlosťou jedným smerom a 0 max. rýchlosťou druhým smerom (TODO: upraviť knižnicu z polohy na rýchlosť).
Tento program ilustruje použitie základných pohybových príkazov. Všimnite si použitie knižnice Servo.h:
#include <Servo.h> // this program uses the Servo library
Servo LeftServo; // create servo object to control both servos
Servo RightServo; // a maximum of eight servos can be created
#define FAST 50 // try to change these values during the test
#define SLOW 5
void setup()
{
LeftServo.attach(9); // attaches the servo on pin 9 to the servo object
RightServo.attach(10); // attaches the servo on pin 10 to the servo object
}
void loop()
{
// FAST FORWARD
LeftServo.write(90 + FAST); // value 90 is in middle, i.e. stop
RightServo.write(90 - FAST); // mirrored position
delay(1500); // go fast forward for 1,5 s
// SLOW FORWARD
LeftServo.write(90 + SLOW); // test varying speed of movement
RightServo.write(90 - SLOW);
delay(1500);
LeftServo.write(90 - FAST); // FAST BACKWARD
RightServo.write(90 + FAST);
delay(1500);
LeftServo.write(90 + FAST); // ROTATE (PIVOT) RIGHT
RightServo.write(90 + FAST);
delay(1500);
LeftServo.write(90 - FAST); // ROTATE (PIVOT) LEFT
RightServo.write(90 - FAST);
delay(1500);
LeftServo.write(90); // STOP both motors
RightServo.write(90);
for(;;); // stop the program operation here
} /* End of Loop */
You may notice that Your motors not stop after the last command.
You can either calibrate sensors using the screwdriver and small trimer inside the motor which is accessible through small opening in the side of the motor, or You can simply switch off the motor using the detach method
LeftServo.detach(); RightServo.detach();
< Previous | Home | Next >