Arduino Simple Elevator

        Here, the basic idea of the elevator system that you can find. Using arduino to create an elevator is so easy. Only you need an algorithm which controls stepper, servo and buttons. Before understand the code, I need to say I can not explain the structure of the elevator. You need to build it yourself. In the video above, the components which are used in the project is represented , so you can google it. For instance, I used a stepper motor to go up and down the cabin of the elevator but if you want, it is possible to change the components. Hovewer, if you use an different element instead a stepper motor then you need to change some lines in the code.

        First let`s see how the cabin can move up or down. Here is the code. The "i" variable shows the number of floor. The movement of the cabin because of variable "i". As you see elevator consist of 4 floor then for each floor, the code is written. First time you have to start the elevator in the first floor. Because elevator can not understand where it is when the system firstly ready to go. Now elevator is ready.For example, push the button 4 which means exactly you want to elevator of the cabin goes up to forth floor. Then, due to if(buttonState4 == HIGH), the codes will be worked inside of this line. As we know i=1 firstly so i<4. Then until i goes to the 3, up() function will be active. So cabin will be on the fourth floor. After that which floor you want to go just push the button !. Here it is good to say , as you see until forth floor, up() function is calling for three times.

        The up() and down() functions are important. If you look at to the code closely, you see up() and down() functions, in the for loop.Inside of the foor loop variable a and b are increased until it is equal to 299. Which makes 300 steps. These steps represent our elevators each floor length.Basicly my stepper can be moved the cabin as a one floor in 300 steps. I mean 300 will be depend on the your system. Also delay() time can be changed to take the one floor. Here is the question, how can you know the how much step you need to take for a one floor or how much time you need ? When I thougt that, first I need to find the one revolution of my stepper as a cm in one milli sec. Then I need to measure the distance one floor... But no !! Just insert your stepper in your system and work it. Give some value after a few trying you find the perfect number. As an example, our one floor distance is closely 10 cm. It is easy to change the number not delay time. Give first some delay then change the number in the for loop.

        Attention !! If you copy and paste the code it is not good idea to understand the idea. Just follow the steps. Then you get the whole points.

        Now we are ready to show the number of each floor using 7 segment display. Before that let me explain the trick. If you see the video, you should see we used an arduino leonardo. Which has no enough pin number to drive an 7 segment display, so It was needed an integreated circuit which is known as a shift register, to drive the 7 segment display only using 3 digital pin. It is great !!!

        I will explain this situation other time. But for now just google it. HOW TO DRIVE 7 SEGMENT DISPLAY USING SHIFHT REGISTER ARDUINO. Or SHIFT REGISTER ARDUINO. then you get what you want exactly. I will give you the code and some explanation which is enough to use.

        Show(numbers[i]); this line represents the floor number on the 7 segment. I said before if you worry about the code, I mean you want to learn how it works, google it. Or you just need to use it then copy the code. Here is the some useful information about the shift register. When you use it in your elevator, it is good idea to use external 5v power supply for seven segment. Do not use arduino as a power supply ! As in the video when cabin is moving the number is not seen . Actually the reason is not about the power supply. Basicly I forgot to insert the line show(numbers[i]); in the up() and down() function :) . After that, I solved. But it is still not clear when the cabin is moving. This is because of the power supply! Again I said do not use 5v pin of arduino. Use external one.

        So here is the final step. The door !!!. Our basic idea when the cabin stop, open the door for a two second then close it. Just it. We use servo to open and close the door. So whole code is blow.

Enjoy the code. If you have any question or anything to ask or to say , do not hasitate , just send me an e-mail. 20/05/2014