View unanswered posts | View active topics It is currently Tue Jul 29, 2014 4:41 am






Reply to topic  [ 5 posts ] 
Color sensor 
Author Message
Rookie

Joined: Wed Jun 05, 2013 6:19 pm
Posts: 3
Post Color sensor
Hello,
i need help please...

I try :

while (SensorValue[colorSensor] == BLACKCOLOR){
//test
}

Don't work???


Wed Jun 05, 2013 6:23 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Color sensor
That is a functional command. Could you post your entire code?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Wed Jun 05, 2013 6:32 pm
Profile WWW
Rookie

Joined: Wed Jun 05, 2013 6:19 pm
Posts: 3
Post Re: Color sensor
Thanks for your time!

//Line reader with color
task main()
{
int moveTo = 1;
int move = 1;

while (true){
nSyncedMotors = synchAB;
do{
motorA = 50;
}while (SensorValue[colorPort] == BLACKCOLOR)

nSyncedMotors = synchNone; // On arrete la synchronisation des moteurs
do{
motorA = -moveTo;
motorB = moveTo;

moveTo = moveTo + move;
if (SensorValue[colorPort] != BLACKCOLOR){
motorA = moveTo;
motorB = -moveTo;

moveTo = moveTo + move;
}
}while (SensorValue[colorPort] != BLACKCOLOR)
}
}


Wed Jun 05, 2013 7:16 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Color sensor
Next time please use the
Code:
[code][/code]
tags when posting code. :wink:

You had some syntax errors in the code, and never defined the port that the sensor was on. I got it to the point where there were no errors, but no guarantees that it's bug free.

Code:
#pragma config(Sensor, S1,     colorPort,               sensorCOLORFULL)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

//Line reader with color
task main()
{
   int moveTo = 1;
   int move = 1;

   while (true){
      nSyncedMotors = synchAB;
      do{
         motor[motorA] = 50;
      }while (SensorValue[colorPort] == BLACKCOLOR);

      nSyncedMotors = synchNone; // On arrete la synchronisation des moteurs
      do{
         motor[motorA] = -moveTo;
         motor[motorB] = moveTo;

         moveTo = moveTo + move;
         if (SensorValue[colorPort] != BLACKCOLOR){
            motor[motorA] = moveTo;
            motor[motorB] = -moveTo;

            moveTo = moveTo + move;
         }
      }while (SensorValue[colorPort] != BLACKCOLOR);
   }
}

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Wed Jun 05, 2013 7:53 pm
Profile WWW
Rookie

Joined: Wed Jun 05, 2013 6:19 pm
Posts: 3
Post Re: Color sensor
Thank you! :D


Thu Jun 06, 2013 4:12 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.