Skip to content

Commit

Permalink
changed pins (read the caption)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Violeta-Tejera committed Oct 4, 2023
1 parent 7374b04 commit 542f36e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Cyberduck-Robot.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
#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;
#define servoNeck A0

// 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(){
Expand All @@ -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
Expand Down Expand Up @@ -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);
}


Expand Down

0 comments on commit 542f36e

Please sign in to comment.