sensorDigitalIn)
#pragma config(Sensor, dgtl2, btn2,
sensorDigitalIn)
#pragma config(Sensor, dgtl3, btn3,
sensorDigitalIn)
#pragma config(Sensor, dgtl4, lmt1,
sensorDigitalIn)
#pragma config(Sensor, dgtl5, lmt2,
sensorDigitalIn)
#pragma config(Sensor, dgtl6, btn4,
sensorDigitalIn)
#pragma config(Sensor, dgtl7, btn5,
sensorDigitalIn)
#pragma config(Sensor, dgtl10, red,
sensorLEDtoVCC)
#pragma config(Sensor, dgtl11, green,
sensorLEDtoVCC)
#pragma config(Sensor, dgtl12, yellow,
sensorLEDtoVCC)
//*!!Code automatically generated by 'ROBOTC' configuration wizard
!!*//
/*
Project Title: VEX Elevator Project
Team Members: Alyssa Hunt, Levi Villarreal, Samantha Trevino, Zachary Stinson
Date: 11/20/14 - 12/9/14
Section: POE A7
Task Description: An elevator must be able to go to three different floors and turn
on lights when their respective buttons are pressed. A safety function must return
the elevator to the first floor if it is not in use for a long time. For our project
however, we also made our elevator able to go sideways in addition to up and down.
Pseudo code: When button 1 is pressed
Elevator moves to floor one
Light Turns on
Elevator stops
When button 2 is pressed
Elevator moves to floor two
Light Turns on
Elevator stops
When button 3 is pressed
Elevator moves to floor three
Light Turns on
Elevator stops
When no button is pressed for 30 seconds
Elevator moves to floor one
Light Turns on
Elevator stops
When button 4 is pressed
Wheels turn clockwise
Wait 1 second
Stop wheels
When button 5 is pressed
Wheels turn counter-clockwise
Wait 1 second
Stop wheels
*/
task main ()
{
while (1 == 1) { // Loop everything in the while loop because 1 always equals
1
// If floor one button pressed
if(SensorValue[btn1] == 0 && SensorValue [lmt1] == 0 ) { // If
the first floor button is pressed, but it is already at the first flor
turnLEDOn(green); // Turn green LED on for 2 seconds
wait(2);
turnLEDOff(green); // Turn green LED off
} // end if-then statement
if(SensorValue[btn1] == 0 && SensorValue [lmt2] == 0 ) { // If the
first floor button is pressed, and it is at the top floor
turnLEDOn(green); // Turn LED on for 1 second
startMotor(port1, -14); // Turn motot on for 1 second Goes down
if(SensorValue(lmt1) == 0){
stopMotor(port1); // Stop Motor
turnLEDOff(green); // Stop LED
}
} // end if-then statement
if(SensorValue[btn1] == 0 && SensorValue [lmt1] == 1 &&
SensorValue [lmt2] == 1) { // If the first floor button is pressed, and it is not at the
top floor or bottom floor
turnLEDOn(green); // Turn LED on for .5 seconds
startMotor(port1, -14); // Turn motor on for .5 seconds
- Goes down
wait (1);
stopMotor(port1); // Turn motor off
turnLEDOff(green); // Turn LED off
} // end if-then statement
wait(2);
stopMotor(port1); // Turn motor off
turnLEDOff(green); // Turn LED off
} // end nested if-then statement
if(SensorValue [lmt1] == 1 && SensorValue
[lmt2] == 1) {
second
wait(1);
stopMotor(port1); // Turn off motor
turnLEDOff(green); // Turn off LED
} // end nested if-then statement
} // end if-then statement