|
Page 1 of 1
|
[ 2 posts ] |
|
| Author |
Message |
|
rg0930
Rookie
Joined: Wed Dec 09, 2009 2:34 pm Posts: 1
|
 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 |
|
 |
|
lololol
Rookie
Joined: Sat Jan 10, 2009 6:26 pm Posts: 14
|
 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 |
|
|
|
Page 1 of 1
|
[ 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
|
|