Maze solving robot HELP!!

Hello All,

I would like to modify attached code in a way to have 3 static Ultrasonic sensors (but i dont know how :frowning: ), without servo motor which was used to rotate one sensor and ping surroundings in attached code. Can anybody help me to remove this and add 3 static sensors? End result should be maze solving robot with 3 ultrasonic sensors.

I’m using servo shield L239D and HC-SR04 and arduino uno.

Big thanks in advance,

Best regards,

Mark

APC_4_ROBOT.ino (9.51 KB)

Why did you write it for a single turreted sensor if you were going to use three sensors instead?

Why not just post the code, so we can read it, without having to download it?

i downloaded this code … i don’t have anything else … unfortunately i don’t how to modify this code. sorry :blush:

unfortunately i don’t how to modify this code

When do you plan to learn?

#define TRIG_PIN A0 // Pin A0 on the Motor Drive Shield soldered to the ultrasonic sensor
#define ECHO_PIN A1 // Pin A1 on the Motor Drive Shield soldered to the ultrasonic sensor
#define TRIG_PIN A2 // Pin A2 on the Motor Drive Shield soldered to the ultrasonic sensor
#define ECHO_PIN A3 // Pin A3 on the Motor Drive Shield soldered to the ultrasonic sensor
#define TRIG_PIN A4 // Pin A4 on the Motor Drive Shield soldered to the ultrasonic sensor
#define ECHO_PIN A5 // Pin A5 on the Motor Drive Shield soldered to the ultrasonic sensor

The end result of this method is not three trigger pins and three echo pins. It is ONE of each, on pins A4 and A5.

NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE); // sets up sensor library to use the correct pins to measure distance.

And, you have ONE sensor that you can use.

Servo myservo;  // create servo object to control a servo

You don’t have a servo. Why do you have an instance of the Servo class?

int readPing() { // read the ultrasonic sensor distance
  delay(70);

The point of using NewPing is to eliminate blocking. Pretty stupid to then deliberately sit around with your thumb up your ass.

Hi markovs83, First, how are you going to solve the maze? For instance, will you just follow, say, the right wall all the time? Will that work? Are you going to use the ultrasounds to make a map of the walls, and spaces that would be hallways, then go back and explore?

What method you use will determine the sensors and arrangement and ....

Hello All,

Big thanks for the reply’s, i’m trying to learn programming, so big thanks for support.

Regarding code, my idea was to modify code to use 3 sensors and compare “cm” from sensors. E.g. If 1st and 2nd sensors are > than 3rd go to into 3rd direction … and so on, compare all the values and choose the largest. Maybe this is dumb idea but in maze i expect to have always 2wals near and one gap (“doors”)

Also i noticed that i have all Analog pins but not declared down … in attach you can find modifications, also stupid and not good programming. :slight_smile: but maybe some progress is visible.

Also this servo, hmm i need to figure how to remove it :slight_smile:

APC_4_ROBOT.ino (13.5 KB)

Hi markovs83 , Let me play with your code today and I'll post to you this evening.

Hi Makov

See attached.
I commented out all references to myServo, which I assume is the PING servo. Everything I commented starts with //SD.

checkPath1(),checkPath2(0 & checkPath3() all set the same variable, curDist. Is that what you want, or do you want curDist1, curDist2 & curDist3 ?

You didn’t define a function checkPath(), used in void Loop(), so I did.

Let me know how your doing.

In the next post, I attached a real nice write-up on mapping with the PING. Definetly check it out!
(It was too big to add to this post)

new_APC_4_ROBOT.ino (14.1 KB)

The write-up on Robot Mapping with PING is to big to attach, so I put a link to it on my web site:

http://www.erocs.me/mapping.html

One of my companies is EROCS, I teach Electronics and Robotics, the other is an Electronics test lab: http://4ctestsystems.com/

Keep me posted.

Hello All,

First of all i just want to thank sdy1 for modifications and document about robot mapping. Big big thanks! :slight_smile:

Today i will take look on ino file that you attached and continue with a work.

I will post again my modifications so everyone can see the progress :slight_smile:

Best regards to all of you and thanks one more time for the support,

:wink:

Thanks, good luck and keep in touch.

Hello All,

Today i was, i think :), pretty much productive, and i learned a lot! :slight_smile: in attach you can find new recoded stuff, and it’s working :slight_smile: but it’s not perfect.

I’m still struggling with logic part: “what should robot do when he has all information’s”

I implemented some IF statements, so if someone wants to take look and give some advice, it would be nice :blush: :blush:

Thanks in advance,

Wish you all the best,

Mark

MyAPC_Robot_NEW.ino (12.4 KB)

I haven't looked at it yet but now you need a good flow chart. Step back, think of what you want done. How do you solve a maze? Also, Look up what a "State Machine" is. It not a real machine but a way to code different conditions, like If... else if.. else if.. on Steroids. You robot goes from one state to another. I'll look at it tomorrow and get back.