View unanswered posts | View active topics It is currently Sun Apr 20, 2014 1:19 pm






Reply to topic  [ 1 post ] 
Finding a Candle 
Author Message
Rookie

Joined: Sun Mar 11, 2012 11:15 pm
Posts: 3
Post Finding a Candle
Hey,

I am working on a project and I am used ROBOTC to program my NXT robot.

For this program I need to use the light senor to locate and go to the candle but I am having trouble getting it to work.

What I need for it to do is check for light and if it finds a strong enough light source to go to the source and just quit the entire program if it does not find a strong enough light source it needs to break out and back into the main function so it can continue on to the next room.

I have the light sensor attached to the robot almost like an arm pointing straight out infront.

If you have any ideas please let me know thanks!!


#pragma config(Sensor, S1, light, sensorLightInactive)
#pragma config(Sensor, S4, Sonar, sensorSONAR)
#pragma config(Motor, motorB, RightWheel, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, motorC, LeftWheel, tmotorNormal, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

void checkLight();

task main ()
{
nMotorPIDSpeedCtrl[motorC] = mtrSpeedReg;
nMotorPIDSpeedCtrl[motorB] = mtrSpeedReg;

motor[motorC] = 100;
motor[motorB] = 100;
wait1Msec(1000);

checkLight();

motor[motorC] = 100;
motor[motorB] = 100;
wait1Msec(5000);

}

void checkLight()
{
if (SensorValue(light) > 60)
{
while (SensorValue(Sonar) > 15 )
{
motor[motorC] = 25;
motor[motorB] = 25;
}
}

else
motor[motorC] = -25;
motor[motorB] = 50;
return;
}


Sun Mar 11, 2012 11:22 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

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.