]> kolegite.com Git - vmks.git/commitdiff
fixed naming conflict in DC_motor_and_servo
authorVladimir Garistov <vl_garistov@gmail.com>
Thu, 11 Nov 2021 23:19:04 +0000 (01:19 +0200)
committerVladimir Garistov <vl_garistov@gmail.com>
Thu, 11 Nov 2021 23:19:04 +0000 (01:19 +0200)
Examples/DC_motor_and_servo/DC_motor_and_servo.ino

index 97fe86b0468fecd901124f32789b2d52214ac6a3..8f1c9a1e0edd9dd96a76e73aeb0133d1943a265f 100644 (file)
@@ -1,12 +1,12 @@
 #include <Servo.h>
 
-#define A1    6
-#define A2    5
-#define EN_L  7
-#define A3    9
-#define A4    11
-#define EN_R  4
-#define SERVO_PIN 10
+#define DRV_A1         6
+#define DRV_A2         5
+#define EN_L           7
+#define DRV_A3         9
+#define DRV_A4         11
+#define EN_R           4
+#define SERVO_PIN      10
 
 Servo aservo;
 
@@ -17,82 +17,82 @@ void turn_right(uint8_t speed);
 
 void setup()
 {
-  pinMode(A1, OUTPUT);
-  pinMode(A2, OUTPUT);
-  pinMode(EN_L, OUTPUT);
-  digitalWrite(A1, LOW);
-  digitalWrite(A2, LOW);
-  digitalWrite(EN_L, HIGH);
-  
-  pinMode(A3, OUTPUT);
-  pinMode(A4, OUTPUT);
-  pinMode(EN_R, OUTPUT);
-  digitalWrite(A3, LOW);
-  digitalWrite(A4, LOW);
-  digitalWrite(EN_R, HIGH);
+       pinMode(DRV_A1, OUTPUT);
+       pinMode(DRV_A2, OUTPUT);
+       pinMode(EN_L, OUTPUT);
+       digitalWrite(DRV_A1, LOW);
+       digitalWrite(DRV_A2, LOW);
+       digitalWrite(EN_L, HIGH);
+       
+       pinMode(DRV_A3, OUTPUT);
+       pinMode(DRV_A4, OUTPUT);
+       pinMode(EN_R, OUTPUT);
+       digitalWrite(DRV_A3, LOW);
+       digitalWrite(DRV_A4, LOW);
+       digitalWrite(EN_R, HIGH);
 
-  aservo.attach(SERVO_PIN);
+       aservo.attach(SERVO_PIN);
 }
 
 void loop()
 {
-  /*
-    digitalWrite(A1, HIGH);
-    analogWrite(A2, 128);
-    digitalWrite(EN_L, HIGH);
-  */
+       /*
+       digitalWrite(DRV_A1, HIGH);
+       analogWrite(DRV_A2, 128);
+       digitalWrite(EN_L, HIGH);
+       */
 
-  //aservo.write(90);
+       //aservo.write(90);
 
-  /*
-    for (uint8_t i = 0; i < 4; i++)
-    {
-        forward(255);
-        delay(5000);
-        turn_right(128);
-        delay(1000);
-    }
-    digitalWrite(EN_L, LOW);
-    digitalWrite(EN_R, LOW);
-  */
+       /*
+       for (uint8_t i = 0; i < 4; i++)
+       {
+               forward(255);
+               delay(5000);
+               turn_right(128);
+               delay(1000);
+       }
+       digitalWrite(EN_L, LOW);
+       digitalWrite(EN_R, LOW);
+       */
 }
 
 void forward(uint8_t speed)
 {
-  analogWrite(A1, speed);
-  digitalWrite(A2, LOW);
-  analogWrite(A3, speed);
-  digitalWrite(A4, LOW);
+       analogWrite(DRV_A1, speed);
+       digitalWrite(DRV_A2, LOW);
+       analogWrite(DRV_A3, speed);
+       digitalWrite(DRV_A4, LOW);
 }
 
 void reverse(uint8_t speed)
 {
-  digitalWrite(A1, LOW);
-  analogWrite(A2, speed);
-  digitalWrite(A3, LOW);
-  analogWrite(A4, speed);
+       digitalWrite(DRV_A1, LOW);
+       analogWrite(DRV_A2, speed);
+       digitalWrite(DRV_A3, LOW);
+       analogWrite(DRV_A4, speed);
 }
 
 void turn_left(uint8_t speed)
 {
-  digitalWrite(A1, LOW);
-  analogWrite(A2, speed);
-  analogWrite(A3, speed);
-  digitalWrite(A4, LOW);
+       digitalWrite(DRV_A1, LOW);
+       analogWrite(DRV_A2, speed);
+       analogWrite(DRV_A3, speed);
+       digitalWrite(DRV_A4, LOW);
 }
 
 void turn_right(uint8_t speed)
 {
-  analogWrite(A1, speed);
-  digitalWrite(A2, LOW);
-  digitalWrite(A3, LOW);
-  analogWrite(A4, speed);
+       analogWrite(DRV_A1, speed);
+       digitalWrite(DRV_A2, LOW);
+       digitalWrite(DRV_A3, LOW);
+       analogWrite(DRV_A4, speed);
 }
 
 void stop_motors()
 {
-  digitalWrite(A1, LOW);
-  digitalWrite(A2, LOW);
-  digitalWrite(A3, LOW);
-  digitalWrite(A4, LOW);
+       digitalWrite(DRV_A1, LOW);
+       digitalWrite(DRV_A2, LOW);
+       digitalWrite(DRV_A3, LOW);
+       digitalWrite(DRV_A4, LOW);
 }