View unanswered posts | View active topics It is currently Mon Nov 24, 2014 5:32 am






Reply to topic  [ 4 posts ] 
Light Sensor / Colour sensor - linefollower 
Author Message
Rookie

Joined: Mon May 20, 2013 6:45 am
Posts: 2
Post Light Sensor / Colour sensor - linefollower
hello,

I'm a completly new person to NXT, and I wanted to use RobotC to programm by NXT 2.0. The problem is:

I have this kind of sensor (http://www.roboshop.pl/media/catalog/pr ... sensor.jpg) and i want to use it in this way - if the robot "see" black line (on white board) to follow the line. But I can not do it. i wrote this kind of program:

Code:
#pragma config(Sensor, S3,     lightSensor,         sensorLightActive)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//


task main()
{
   wait1Msec(50);                        // The program waits 50 milliseconds to initialize the light sensor.

   while(true)                           // Infinite loop
   {
      if(SensorValue(lightSensor) < 45)  // If the Light Sensor reads a value less than 45:
      {
        motor[motorC] = 50;                  // Motor C is run at a 20 power level.
     }
      else                               // If the Light Sensor reads a value greater than or equal to 45:
      {
        motor[motorB] = 100;                  // Motor B is run at a 20 power level.
      }
   }
}


of course i gave in Robot -> Motors and Sensors Setup -> Sensors -> S3 LightSensor Reflected Light (active) but my robot detects nothing! Even red light isn't working (But if I choose only the burning of the red light, the red LED is lit).

Anyone knows what is going on? Why my LineFollower doesn't recognize or detect anything? Thank for any replies :)

Marcin


Mon May 20, 2013 8:40 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3289
Location: Rotterdam, The Netherlands
Post Re: Light Sensor / Colour sensor - linefollower
Try configuring that port as Colour Sensor Red, like this:
Attachment:
2013-05-20_17-13-58.png
2013-05-20_17-13-58.png [ 13.42 KiB | Viewed 3037 times ]

That will change your file to the following:
Code:
#pragma config(Sensor, S3,     lightSensor,    sensorCOLORRED)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  wait1Msec(50);                        // The program waits 50 milliseconds to initialize the light sensor.

  while(true)                           // Infinite loop
  {
    if(SensorValue(lightSensor) < 45)  // If the Light Sensor reads a value less than 45:
    {
      motor[motorC] = 50;                  // Motor C is run at a 20 power level.
    }
    else                               // If the Light Sensor reads a value greater than or equal to 45:
    {
      motor[motorB] = 100;                  // Motor B is run at a 20 power level.
    }
  }
}


= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon May 20, 2013 11:15 am
Profile WWW
Rookie

Joined: Mon May 20, 2013 6:45 am
Posts: 2
Post Re: Light Sensor / Colour sensor - linefollower
huhu, come to Poland, you have a big beer from me! :)

Thanks a lot. :)


Tue May 21, 2013 9:33 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3289
Location: Rotterdam, The Netherlands
Post Re: Light Sensor / Colour sensor - linefollower
Thanks! I may take you up on it some day :)

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue May 21, 2013 1:41 pm
Profile WWW
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:  
cron



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