top of page

VEX ELEVATOR PROJECT

My group and I were to build something from the VEX parts and program the machine to do a certain task. In our case we built an elevator. The elevator has three levels (base level, first level, second level) and bump switches are attached to each. When someone presses a bump switch the elevator will travel up or down to the bump switch where it hits a limit switch that stops it. Along with that, the elevator will return back to base level after being at another level for an extended amount of time. To the right is a video of how it works. 

program code for our project:

 

nt Nfloor = 1;

void checkFloor(){
    if (SensorValue[limit1] == 1){
        Nfloor = 1;
    }
    if (SensorValue[limit2] == 1){
        Nfloor = 2;
    }
    if (SensorValue[limit3] == 1){
        Nfloor = 3;
    }
}

void toFloor(int dest){
    if (dest > Nfloor){
        while(dest > Nfloor){
            motor[elevator] = 60;
            checkFloor();
        }
        motor[elevator] = 0;
    }
    if (dest < Nfloor){
        while(dest < Nfloor){
            motor[elevator] = -60;
            checkFloor();
        }
        motor[elevator] = 0;
    }

}

int waitT = 0;

task main(){
    while(true){
        if (SensorValue[floor1] == 1){
            toFloor(1);
            waitT = 0;
        }

        if (SensorValue[floor2] == 1){
            toFloor(2);
            waitT = 0;
        }

        if (SensorValue[floor3] == 1){
            toFloor(3);
            waitT = 0;
        }
        if (waitT > 100000 & Nfloor != 1){
            toFloor(1);
        } else {
            waitT = waitT + 1;
        }

        checkFloor();
    }

© 2023 by Digital Marketing. Proudly created with Wix.com

bottom of page