Thing 1
Thing 1
!!*//
/*
Project Title:3.1.1+
Team Members: Michael and Rofin
Date: 1/28/16
Section: Block 4
Task Description:
We created a variable called brightest. It will remeber the brightest
light detected by the light sensor. Then when the limitSwitch is hit, the value will be reset.
Pseudocode:
We begin the program in the task main. We then made a global variable called brightest.
Then in the while loop when 1=1, we set the value of brightest to 100000 as the starting
value. We then made another while loop that works when the limit switch has a value of 0.
Then if the sensor value of the lightSensor is less than brightest, brightest takes on the
value of the lightSensor. So brightest remebers the brightest light it senses.
The program is reset when the limitSwitch is pressed.
*/
task main()
{
int brightest;
while (1==1)
{
brightest = 100000;
while (SensorValue(limitSwitch)==0)
{
if (SensorValue(sonar)<brightest)
{
brightest= SensorValue(sonar);
}
}
}
Section: Block 4
Task Description:you press the limit switch and then machine starts if it is pressed agian it stops.
Pseudocode:
Program begins, insert code within curly braces,defined a variable,instantiated a variable,while
the motorCount is less than 20,start left motor slowly
if limit switch is pressed,if limit switch is pressed,stop left motor,start left motor slowly,wait .5
second,stop the left motor,
wait .5 second,add one to the motorCount
*/
task main()
{
int motorCount;
motorCount = 0;
while (motorCount < 20)
{
startMotor(rightMotor, -50);
if(SensorValue(limitSwitch)==1)
{
stopMotor(rightMotor);
startMotor(rightMotor,25);
wait(.5);
//wait .5 second
stopMotor(rightMotor);
wait(.5);
//wait .5 second
motorCount ++;
}
}
}