Friday, December 6, 2024

Robot servo motor udirdah

 #include <Servo.h>

Servo myservo;  // create servo object to control a servo
Servo myservo1;
void setup()
{
Serial.begin(9600);
  // attaches the servo on pin 10 to the servo object
  myservo.attach(10);
  myservo1.attach(9);

}

void loop()
{
myservo.attach(10);myservo1.attach(9); uragshaa();delay(3000);zogs();delay(2000);
myservo.attach(10);myservo1.attach(9); baruun();delay(1300);zogs();delay(2000);
myservo.attach(10);myservo1.attach(9); uragshaa();delay(3000);zogs();delay(2000);
myservo.attach(10);myservo1.attach(9); baruun();delay(1300);zogs();delay(2000);
myservo.attach(10);myservo1.attach(9); uragshaa();delay(3000);zogs();delay(2000);
myservo.attach(10);myservo1.attach(9); baruun();delay(1300);zogs();delay(2000);
myservo.attach(10);myservo1.attach(9); uragshaa();delay(3000);zogs();delay(2000);
myservo.attach(10);myservo1.attach(9); baruun();delay(1300);zogs();delay(200000);

}
void uragshaa(){
myservo.write(180);
myservo1.write(0);
}
void hoishoo(){
myservo.write(0);
myservo1.write(180);
}
void baruun(){
myservo.write(180);
myservo1.detach();
}
void zuun(){
myservo1.write(0);
myservo.detach();
}
void zogs(){
myservo.detach();
myservo1.detach();
}

2 дугуй удирдах 360 servo

 #include <Servo.h>

Servo myservo;  // create servo object to control a servo
Servo myservo1;
void setup()
{
Serial.begin(9600);
  // attaches the servo on pin 10 to the servo object
  myservo.attach(10);
  myservo1.attach(9);

}

void loop()
{
  myservo.write(180);
  myservo1.write(0);
}