I need my robot to move up until the IR sensor reaches a defined value then stop. I need that about of time to be taken as a value i can use to tell it how far it moves backwards. How could I do that?

Thu Nov 14, 2013 11:18 am

JohnWatson

Site Admin

Joined: Thu May 24, 2012 12:15 pmPosts: 722

Re: I have a complicated autonomos problem I need help with.

What code do you have so far? Please post what you have so far using the [code] tags and we'll be more than happy to take a look at with you.

Also, try listing the behaviors you want the robot to perform (move forward until IR sensor reaches a value, stop, record amount of time, move backwards for amount of time) and then slowly break each behavior down into smaller behaviors, which can then be broken down into individual lines of code. As always, make sure to start with your first behavior (move forward until IR sensor reaches a value) before moving on to the other behaviors.

First off, your else statement will be contradicting your first if statement, so you might want to look at my fix. Im just assuming that < 7 means to move forward here. Here's some code with timers that I would use, I'm not sure if it works since I've never actually used the timer function but it should be fine.

So the int valTime is constantly being updated to the built in timer T1 while the IRSeeker is < 7. The ClearTimer function will set T1 to 0, I'm just assuming you start off in the process you want to time. If not then just clear it right before you do this. Then you can just use valTime in a wait1msec function. Hopefully that helps.

p.s. - im not sure what your "hi;" does, but I will just assume its part of hitechnic-irseeker-v2.h which I don't use, I just use SensorValue for the IRSeeker.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum