Thursday, January 4, 2024

motor code

 

#include <AFMotor.h>
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
void setup() {
  // put your setup code here, to run once:
  motor1.setSpeed(255);  //1R MOTORIIN HURD
  motor2.setSpeed(168);  //2R MOTORIIN HURD
}
void loop() {
  // put your main code here, to run repeatedly:
  uragshaa();delay(2000);    zogs(); delay(1000);
  baruun(); delay(300);   zogs(); delay(1000);
  uragshaa();delay(2000);    zogs(); delay(1000);
  baruun(); delay(300);   zogs(); delay(1000);
  uragshaa();delay(2000);    zogs(); delay(1000);
  baruun(); delay(300);   zogs(); delay(1000);
  uragshaa();delay(2000);    zogs(); delay(1000);
  baruun(); delay(300);   zogs(); delay(1000);
  }
void uragshaa() {
  motor1.run(FORWARD);
  motor2.run(FORWARD);
}
void hoishoo() {
  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
}
void zogs() {
  motor1.run(RELEASE);
  motor2.run(RELEASE);
}
void baruun() {
  motor1.run(FORWARD);
  motor2.run(RELEASE);
}
void zuun() {
  motor1.run(RELEASE);
  motor2.run(FORWARD);
}


/*

////////////////////////////////////////////////////////////////////////

Motor shalgah

#include<AFMotor.h>
AF_DCMotor motor1(3);
void setup() {
  // put your setup code here, to run once:
motor1.setSpeed(255);
}

void loop() {
  // put your main code here, to run repeatedly:
motor1.run(FORWARD);
}
*/

No comments:

Post a Comment