From: Vladimir Garistov Date: Thu, 11 Nov 2021 23:19:04 +0000 (+0200) Subject: fixed naming conflict in DC_motor_and_servo X-Git-Url: https://kolegite.com/gitweb/?a=commitdiff_plain;h=de7d7f2b820d068cc8dd827b6d08c8d677d2acd8;p=vmks.git fixed naming conflict in DC_motor_and_servo --- diff --git a/Examples/DC_motor_and_servo/DC_motor_and_servo.ino b/Examples/DC_motor_and_servo/DC_motor_and_servo.ino index 97fe86b..8f1c9a1 100644 --- a/Examples/DC_motor_and_servo/DC_motor_and_servo.ino +++ b/Examples/DC_motor_and_servo/DC_motor_and_servo.ino @@ -1,12 +1,12 @@ #include -#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); }