Help: Light Sensor Counting =(
Help: Light Sensor Counting =(
Hi guys,
Need a little help here with NXT G. =(
how do i program, using 1 light sensor, to go across 5 black lines and after passing the fifth line, reverse back(reversing part doesnt have to count) ..
been trying out for hours =(
thanks..
Need a little help here with NXT G. =(
how do i program, using 1 light sensor, to go across 5 black lines and after passing the fifth line, reverse back(reversing part doesnt have to count) ..
been trying out for hours =(
thanks..
Re: Help: Light Sensor Counting =(
A basic implementation (not allowing for scalability, etc):
Make the robot move forward continuously. This can be done with the Motor or Move Block.
Use a Loop Block, and set it to repeat 5 times. (Counter?) Inside it, put a Wait Block that waits for the Light sensor to be greater than 50% (or some other value). Then add another Wait Block next to the last one, that waits for the Light sensor to be less than 50%.
At the end of the program (outside the Loop Block), put a Motor or Move Block that reverses your robot.
You may wish to calibrate your light sensor. See the first part of the Claw Car with Game Controller program for an example of how to do that.
Make the robot move forward continuously. This can be done with the Motor or Move Block.
Use a Loop Block, and set it to repeat 5 times. (Counter?) Inside it, put a Wait Block that waits for the Light sensor to be greater than 50% (or some other value). Then add another Wait Block next to the last one, that waits for the Light sensor to be less than 50%.
At the end of the program (outside the Loop Block), put a Motor or Move Block that reverses your robot.
You may wish to calibrate your light sensor. See the first part of the Claw Car with Game Controller program for an example of how to do that.
Last edited by muntoo on 30 Aug 2011, 18:50, edited 1 time in total.
Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
-
- Posts: 346
- Joined: 27 Sep 2010, 03:05
- Contact:
Re: Help: Light Sensor Counting =(
Most people forget that robots count VERY fast, but they aren't very smart. So, you may tell it to move until it sees a line, and that's fine. But you tell it to move to the next line, and the robot thinks it's already there...
Steve
Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
Re: Help: Light Sensor Counting =(
yeah. this is exactly what happened... upon reaching the first line the loops stops even thou i set it to 5. =(hassenplug wrote:Most people forget that robots count VERY fast, but they aren't very smart. So, you may tell it to move until it sees a line, and that's fine. But you tell it to move to the next line, and the robot thinks it's already there...
Steve
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Help: Light Sensor Counting =(
That's why you not only need to see the line, but also see the other color. As muntoo said, until > 50 then until < 50 (or whatever the case may be).
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: Help: Light Sensor Counting =(
so its. (Loopx5) (>50)(forward)(<50)(forward) (Loopx5) (reverse) ?
Re: Help: Light Sensor Counting =(
It's:moofiee wrote:so its. (Loopx5) (>50)(forward)(<50)(forward) (Loopx5) (reverse) ?
Code: Select all
Forward (Forever)
Loop 5
{
Wait until >50
Wait until <50
}
Reverse
Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Re: Help: Light Sensor Counting =(
Thanks for the help all.
Muntoo I tried the way as u mention. The robot started reversing upon detecting the first line still.
Muntoo I tried the way as u mention. The robot started reversing upon detecting the first line still.
Re: Help: Light Sensor Counting =(
That's because the light sensor is "just within" the range of 49% - 51%, so the values oscillate between the two very quickly for potentially various reasons. (Lighting conditions, imperfection of the line, sensor error, etc.)
In short, you should try:
You may wish to wait longer or shorter than 100ms (0.1s); some testing is required.
In short, you should try:
Code: Select all
Forward (Forever)
Loop 5
{
Wait until >50%
Wait 100 milliseconds
Wait until <50%
Wait 100 milliseconds
}
Reverse
Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Re: Help: Light Sensor Counting =(
I would rather set the threshold for < to a lower value then the one for >. This because timing is always difficult as it depends on robot speed.muntoo wrote:That's because the light sensor is "just within" the range of 49% - 51%, so the values oscillate between the two very quickly for potentially various reasons. (Lighting conditions, imperfection of the line, sensor error, etc.)
In short, you should try:You may wish to wait longer or shorter than 100ms (0.1s); some testing is required.Code: Select all
Forward (Forever) Loop 5 { Wait until >50% Wait 100 milliseconds Wait until <50% Wait 100 milliseconds } Reverse
Code: Select all
Forward (Forever)
Loop 5
{
Wait until >50%
Wait until <40%
}
Reverse
My blog: nxttime.wordpress.com
Who is online
Users browsing this forum: No registered users and 1 guest