View unanswered posts | View active topics It is currently Sat Dec 20, 2014 4:54 pm






Reply to topic  [ 4 posts ] 
Programing the robot to use the light sensor to find light 
Author Message
Rookie

Joined: Wed Nov 20, 2013 10:44 am
Posts: 2
Post Programing the robot to use the light sensor to find light
Hi

Anyone can help with programming lego mindstorms nxt, with 2 motors and one light sensor, and sonic sensor.

I know how to program sonic sensor to avoid wall and drive.
but when it comes to follow light sensor, i have try it, but it is diffecult.

I have been reading this site about how to follow light sensor: they use 2 light sensors
http://www.robotc.net/wiki/Tutorials/Ar ... find_light

Can someone help me with programming?

best regards

dahir :D


Wed Nov 20, 2013 10:51 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1368
Post Re: Programing the robot to use the light sensor to find lig
To follow a line, you need at least 2 light sensors. However, if you follow the edge of the line, you only need one light sensor. First, break the problem down into pseudo code, then translate it into real code. For example:
Code:
if the robot is on the left side of the line edge
    turn right
else if the robot is on the right side of the line edge
    turn left
else
    go straight

Then think about how to determine "left side of the line edge" and "right side of the line edge"? Once you determine that you can translate the above to real code.


Wed Nov 20, 2013 2:28 pm
Profile
Rookie

Joined: Wed Nov 20, 2013 10:44 am
Posts: 2
Post Re: Programing the robot to use the light sensor to find lig
the robot should not follow the edge of the line, but it should follow light source...
just like this video...

http://www.youtube.com/watch?v=PvgyTIMksA4


Tue Nov 26, 2013 8:11 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1368
Post Re: Programing the robot to use the light sensor to find lig
italialool wrote:
the robot should not follow the edge of the line, but it should follow light source...
just like this video...

http://www.youtube.com/watch?v=PvgyTIMksA4

Sorry, I misunderstood your question. To follow a light source using two light sensors, it compares the light intensities from the left and the right sensors to determine whether to turn left or right. With only one light sensor, it is more difficult but still doable. Instead of comparing the light intensity to a second light sensor, you compare it with the previous reading of the same light sensor. So if the robot is turning the wrong way, the light intensity now is lower than before, you turn the other way. You can even do a little bit of Proportional control on it. For example, to do PID control you need to compute the "error" which is the difference between "current position" and the "target position". In this case, it is the difference between the previous light sensor reading and the current light sensor reading. Let me know if you have difficulty implementing it.


Tue Nov 26, 2013 3:37 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.