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

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

Similar projects you might like

PHPoc Blue to Control Door Knob by MQTT Protocol and Cortana
Intermediate
  • 410
  • 9

Programming a PHPoc Blue board to control a servo motor to rotate the knob of a door using MQTT Protocol through voice command.

GPS Tracking Using Helium, Azure IoT Hub, and Power BI
Intermediate
  • 4,849
  • 20

Full instructions

Building a wireless, battery-powered GPS tracker using a Helium Atom, Arduino Zero, Azure IoT Hub, and Power BI.

Humidity Monitor Mobile App (Windows 10 IoT + Xamarin)
Intermediate
  • 314
  • 3

Full instructions

Put your Sense HAT readings into the cloud and derive insights on your phone. Built on Windows 10 IoT, .Net Core, and Xamarin Forms.

Wikia Alexa Skill Builder (Elite: Dangerous Wiki Skill)
Intermediate
  • 410
  • 2

Full instructions

Wish you could talk to your favorite Wikia Wiki? With the help of Alexa, now you can!

Adding RC Transmitter/Receiver to Control Mecanum Bot
Intermediate
  • 985
  • 8

Full instructions

We previously showed our Mecanum Bot being controlled by a wireless Xbox controller, now we added RC transmitter/receiver.

ConnectTheDots with Particle Azure IoT Hub Integration
Intermediate
  • 836
  • 8

Protip

This project will allow you to connect your Particle device into an Azure IoT Hub for viewing data in real-time through an ASP.NET web app!

Add projectSign up / Login