ELEGOO Robot

I recently purchased a Smart Car Robot V1.0 from ELEGOO off of Amizon. The problem I'm having is the right side isn't picking up the whole arduino program that is uploaded. It's a program from the arduino DVD that came with the robot kinda like a diagnostics type thing that after it's put to gether you upload these program to make sure everything is good The left side worked fine but the right side does not. here is the program { pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); pinMode(ENA,OUTPUT); digitalWrite(ENA,HIGH); } void loop() { digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); //Right wheel forward delay(500); digitalWrite(IN1,LOW); digitalWrite(IN2,LOW); //Right wheel stop delay(500); digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); //Right wheel back delay(500); digitalWrite(IN1,LOW); digitalWrite(IN2,LOW); //Right wheel stop delay(500); }

it goes forward, stops, and it does not go backward. The right side does go back-n-forth because I checked with a different program. I did the obstacle avoidance program and only yhe left side worked. I need this to work because it's a college project. Also can anyone write me a program to use the ultra sonic (so long as I get this part figured out) so that the robot will follow a wall 3 inches on the right all the way around a maze. any help would be extremely appreciated.

Hi Valco, I don't know the bot your talking about, but that code does not tell that bot to go forward! Also if there is an ENA to enable motor A is there not an ENB for motor B or does ENA do both. We really need to see a schematic or drawing of how things are connected, what power are you using? what is the driving chip for the motors.

Give us a clue then we can help more, my crystal ball is broken and I can see what you don't tell me.

Take a look here for my bots: www.melsaunders.co.uk under electroics of course..

Hope it helps, regards.

Mel.

Yes, ENA controls motor A and ENB controls motor B, also this code does tell the motor to go forward because that is the part of the code that works but it does not go backwards. I ran the same code (except for the left side) for the left rotation. Here is the hole code for the right & left: L298N boaard

int ENB=5; int IN3=7; int IN4=6; void setup() { pinMode(IN3,OUTPUT); pinMode(IN4,OUTPUT); pinMode(ENB,OUTPUT); digitalWrite(ENB,HIGH); } void loop() { digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); //Left wheel forward delay(500); digitalWrite(IN3,LOW); digitalWrite(IN4,LOW); //Left wheel stop delay(500); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); //Left wheel back delay(500); digitalWrite(IN3,LOW); digitalWrite(IN4,LOW); //Left wheel stop delay(500); }

int ENA=10; int IN1=9; int IN2=8; void setup() { pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); pinMode(ENA,OUTPUT); digitalWrite(ENA,HIGH); } void loop() { digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); //Right wheel forward delay(500); digitalWrite(IN1,LOW); digitalWrite(IN2,LOW); //Right wheel stop delay(500); digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); //Right wheel back delay(500); digitalWrite(IN1,LOW); digitalWrite(IN2,LOW); //Right wheel stop delay(500); }

So what you're actually saying is that you have 2 separate small sketches and when you load the one for the Left motor it works, forward and back. Then when instead you load the other sketch for the Right motor that one goes forward but doesn't go backward. Is that correct ?

But you also said " The right side does go back-n-forth because I checked with a different program". So what differences are there between the code in that working program and the code in the failing one ? Or even simpler, why not just use the code from the working program ?

My guess is one of the pin numbers is wrong, but it's only a guess.

Steve

Hi Valco, If that's the full code then! you have NOT enabled both motors (no ENA) or used pinMode to set the I/O pins up!! 2 motors so 4 pins needed, 2 Enables, so 6 pins to set up altogether. You're only using IN3 and IN4 which is only one motor, what about IN1 and In2?? where are they?

Sorry I see what you did: You should define pins at the start of your program, also set up pins in the setup loop not half way into your code, if you do then they only work within the function!!

Do a bit of cut and paste move all pinMode setting to the top in a setup loop, also pin defs, etc. Good coding and a tidy layout will help you.

Regards

Mel.

I suspect that's 2 completely separate sketches. With 2 x void setup() and 2 x void loop() it's certainly never compiled as it is.

Steve

Hi, If Valco can't give use the proper code he's using then how can we help! What's the point, what's he trying to do?? just combine the code so both motors run at the same time, and even in the same direction (well one CW and one CCW).

Regards

Mel.