Basic Loop Program

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
king_creole
Posts: 3
Joined: 02 Jan 2014, 14:27

Basic Loop Program

Post by king_creole »

Hello! Total newbie here. I just got the Mindstorm EV3 for my 10-year old son and am trying to learn the basics in order to guide him. But I am not a technically minded person, and I know almost nothing about the software features. So, my question here is very simple: How do I program the robot to react immediately when the infrared sensor detects an obstacle?

I'm using the Track3r robot that my son built right out of the box. All I'm trying to do is get it to go forward, right 30º, and left 60º, over and over in a wide circle until the infrared sensor detects an obstacle, at which point it should back up and turn left.

It works, but the problem I have is that it runs through the whole forward cycle (forward, right, left) before backing up. I want it to react as soon as it detects an obstacle, i.e., if it turns right only 5º and detects a chair leg, I want it to back up immediately.

Image
ninjaman1138
Posts: 7
Joined: 07 Mar 2014, 23:29

Re: Basic Loop Program

Post by ninjaman1138 »

hello
have you managed to get this working yet?

the only thing I would suggest is an if statement or while statement but that is using "nxc"(not exactly C).
I don't know how the programme for ev3 works. you want to put in something that says "if this is true, go forward".
if false then the robot should go through the backing up routine. sorry I couldn't be any more help, check youtube.
h-g-t
Posts: 552
Joined: 07 Jan 2011, 08:59
Location: Albania

Re: Basic Loop Program

Post by h-g-t »

I'm not familiar with EV3 either but it looks as if you have put all the turns in a loop before backing up, which is exactly what you describe the robot acting.

Perhaps you should just set it to run in a circle until it hits an obstacle (inside the IF loop) then telling it to back up.

This sounds very like the sort of logic in a basic 'line follower' program' - there are dozens on the web which you can study.

Here is one, uses the light sensor but the effect is similar -

https://sites.google.com/site/gask3t/le ... e-follower
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 8 guests