View unanswered posts | View active topics It is currently Mon Sep 01, 2014 3:07 pm






Reply to topic  [ 2 posts ] 
Mouse Robot 
Author Message
Rookie

Joined: Wed Dec 09, 2009 2:34 pm
Posts: 1
Post Mouse Robot
My project is a mouse that is searching for cheese; it stops to eat cheese it finds. While its searching it avoids objects.
The part of the program that makes the mouse search and avoid objects is working, but the part that uses a light sensor to find the "cheese" (blank piece of paper) is not working properly.


#pragma config(Sensor, S1, lightSensor, sensorLightActive)
#pragma config(Sensor, S2, sonarSensor, sensorSONAR)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()

{
while(true)
{
while(SensorValue[sonarSensor] > 20)
{

motor[motorA] = 75;
motor[motorB] = 75;

//while (SensorValue[lightSensor] > 18)
//
//{
//motor[motorA] = 0;
//motor[motorB] = 0;
//wait1Msec(3000);
//}

}

motor [motorA]= -50;
motor [motorB]= -50;
wait1Msec(500);
motor [motorA]= -50;
motor [motorB]= 0;
wait1Msec(600);

}
}


Wed Dec 09, 2009 3:17 pm
Profile
Rookie

Joined: Sat Jan 10, 2009 6:26 pm
Posts: 14
Post Re: Mouse Robot
Try it like that:

//*!!Sensor, S1, lightSensor, sensorLightActive, , !!*//
//*!!Sensor, S4, sonarSensor, sensorSONAR, , !!*//

const tSensors lightSensor = (tSensors) S1; //sensorLightActive //*!!!!*//
const tSensors sonarSensor = (tSensors) S4; //sensorSONAR //*!!!!*//


task main()

{
while(true)
{
while(SensorValue[sonarSensor] > 20)
{
motor[motorA] = 75;
motor[motorB] = 75;
}

while (SensorValue[lightSensor] > 30)
{
motor[motorA] = 0;
motor[motorB] = 0;
wait1Msec(3000);
}

}

motor [motorA]= -50;
motor [motorB]= -50;
wait1Msec(500);
motor [motorA]= -50;
motor [motorB]= 0;
wait1Msec(600);

}


Sun Feb 07, 2010 9:38 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.