From 542f36eac87a998f4e99034fc0ff5199a3e67bd4 Mon Sep 17 00:00:00 2001 From: Violeta-Tejera <80209320+Violeta-Tejera@users.noreply.github.com> Date: Wed, 4 Oct 2023 21:58:31 +0200 Subject: [PATCH] changed pins (read the caption) Servo.h conflicts with analogRead for pins 9 and 10. I had one of the enables of the L298n driver plugged in pin 10, so I changed it to pin 6. --- Cyberduck-Robot.ino | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Cyberduck-Robot.ino b/Cyberduck-Robot.ino index c424609..d1792e4 100644 --- a/Cyberduck-Robot.ino +++ b/Cyberduck-Robot.ino @@ -5,11 +5,11 @@ #define right_in2 3 #define left_in3 4 #define left_in4 5 -#define enableLeft 10 //ENB +#define enableLeft 6 //ENB #define enableRight 11 //ENA // Motors -#define stdSpeed 75 +#define stdSpeed 85 // Servo Servo neck; @@ -17,7 +17,7 @@ Servo neck; // Sensors const int sensorCount = 5; -int sensorPins[] = {8, 7, 6, 12, 13}; // From left to right (travelwise) +int sensorPins[] = {8, 7, 10, 12, 13}; // From left to right (travelwise) int sensorValues[sensorCount]; void setup(){ @@ -38,11 +38,11 @@ void setup(){ } void loop(){ - //control_robot(); + control_robot(); //test_motor(); - test_servo(); + //test_servo(); } // @brief This method will update the array sensorValues with the current digital read of all the sensors in the array @@ -70,12 +70,16 @@ void control_robot(){ if(left1 == 0 and right1 == 0){ forwardMovement(stdSpeed, stdSpeed); + neck.write(90); }else if(left1 == 0 and right1 == 1){ turnRight(stdSpeed); + neck.write(60); }else if(left1 == 1 and right1 ==0){ turnLeft(stdSpeed); + neck.write(120); }else{ forwardMovement(stdSpeed, stdSpeed); + neck.write(90); }