View unanswered posts | View active topics It is currently Sat Jun 25, 2016 10:58 pm

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Programing the robot to use the light sensor to find light
Author Message
Rookie

Joined: Wed Nov 20, 2013 10:44 am
Posts: 2
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

Wed Nov 20, 2013 10:51 am
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
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 rightelse if the robot is on the right side of the line edge    turn leftelse    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
Rookie

Joined: Wed Nov 20, 2013 10:44 am
Posts: 2
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
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning

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