Things used in this project

Hardware components:
W2n7xihmvtbrsn3ltjpc
LEGO MindStorms EV3 Programming Brick / Kit
2 motors
×1
Dsc 0159
Husarion RoboCORE
×1
Omron b3f 1000 image 75px
SparkFun Pushbutton switch 12mm
9 buttons
×1
Adafruit industries ada260 image 90px
USB-A to Mini-USB Cable
×1
Software apps and online services:
Vs2015logo
Microsoft Visual Studio 2015
Hand tools and fabrication machines:
09507 01
Soldering iron (generic)

Code

Elevator codeC#
Elevator operates on limit switches made from buttons which indicate on what floor is the elevator. 3 other buttons outside the elavator are for calling it on desired floor. 3 buttons inside the elavator are used to choose destinantion of the elevator. Code is based on functions and loops.
#include <hFramework.h>

using namespace hFramework;


void door_open(){
hMot2.setPower(400);
	hMot2.rotRel(-90);

	//hMot2.rotAbs(90);

}

void door_close(){
hMot2.setPower(400);
	hMot2.rotRel(90);

	//hMot2.rotAbs(90);

}

void on_czek_off_door()
{
    door_open();
    sys.delay(10000);
    door_close();
}




void home_elevator(){
    hExt2.pin1.setIn_pd();//krancowka dolna

	hMot1.setPower(300);
	while(hExt2.pin1.read()==0){
		sys.delay(50);
	}
	hMot1.setPower(0);
}

void semi_elevator(){
    hExt2.pin1.setIn_pd();//krancowka dolna
    hExt2.pin2.setIn_pd();//krancowka srodkowa
    hExt2.pin3.setIn_pd();//krancowka gorna

    if(hExt2.pin1.read()==1)
    {
        hMot1.setPower(-300);
        while(hExt2.pin2.read()==0){
            sys.delay(50);
        }
        hMot1.setPower(0);

    }
    if(hExt2.pin3.read()==1)
    {
        hMot1.setPower(300);
        while(hExt2.pin2.read()==0){
            sys.delay(50);
        }
        hMot1.setPower(0);
    }


}



void end_elevator(){
    hExt2.pin3.setIn_pd();//krancowka gorna

	hMot1.setPower(-300);
	while(hExt2.pin3.read()==0){
		sys.delay(50);
	}
	hMot1.setPower(0);
}





void buttons_thread_loop()
{
    //przyciski zewnatrz
    hExt1.pin1.setIn_pd();
    hExt1.pin3.setIn_pd();
    hExt1.pin2.setIn_pd();

    //przyciski wewnatrz
    hExt1.pin5.setIn_pd();
    hExt1.pin6.setIn_pd();
    hExt1.pin7.setIn_pd();



	while(true){


        //przyciski zewnetrze

        //jazda na 1 pietro
		if((hExt1.pin1.read()==1)||(hExt1.pin5.read()==1))
		{
            sys.delay(20);
            if((hExt1.pin1.read()==1)||(hExt1.pin5.read()==1))
            {
                home_elevator();
                on_czek_off_door();

            }
		}


        //jazda na 2 pietro
		if((hExt1.pin3.read()==1)||(hExt1.pin6.read()==1))
		{
            sys.delay(20);
            if((hExt1.pin3.read()==1)||(hExt1.pin6.read()==1))
            {
                semi_elevator();
                on_czek_off_door();

            }
		}



        //jazda na 3 pietro
		if((hExt1.pin2.read()==1)||(hExt1.pin7.read()==1))
		{
            sys.delay(20);
            if((hExt1.pin2.read()==1)||(hExt1.pin7.read()==1))
            {
                end_elevator();
                on_czek_off_door();
            }
		}

    }

}




void hMain()
{

    //end_elevator();
    //buttons_thread_loop();
    // create thread handling buttons, so you can do other work in hMain
    sys.taskCreate(buttons_thread_loop);

    //while (true) {
      //  LED1.toggle();
        //sys.delay(500);
    //}
}

Credits

13010729 1077528558985872 519975749634535934 n
Jakub Belniak
1 project • 0 followers
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login