need programming code arduino uno for elevator 3 floors

good night.
I'm making a three-floor elevator project using dc motor and a motor driver. door move also use dc motor. to stop at every floor using octocoupler. push button as the initial order.

Well you posted under guidance, yet your subject makes it seem you want a full solution.... which?

First thing you need to do is design the rules that govern the way the elevator will work. That is likely to be the difficult part- deciding what should happen when various buttons are pressed under various circumstances.

And to respond to buttons, you first need to know how to read buttons and output to motors. Have you got the coding experience for that yet?

sorry i just learning arduino. Thank you for the advice. I will try to learn

if you do not mind please give me a reference. thank you

http://forum.arduino.cc/index.php/topic,148850.0.html

read item 4 carfully

read 7 so you understand it.

thanks sir

Well to start learning the coding you should work through the examples here.

Think about how to design an elevator's rules... it's not trivial. That's got nothing to do with Arduino as such, or any particular language for that matter, it's a matter of you defining the actions you want. That involves a lot of thought before you go any where near a program.

there are typically 3 steps

first, write down your sequence as you think it should be. make an outline.
use a pencil, leave lots of open lines.
re-do it as you find you have to change things around,

create a mechanical drawing of the bits, the lights, the motor, the switches, make sure you have things like part numbers and such.

collect the data sheets for each and every part. make sure your motor drivers work with your motors, etc

thrid thing is to create a schematic. there are lots of pictures of Arduinos. copy one, put it in PAINT, and then label the in's and out's as you think you want them. this schematic would correspond to the mechanical drawing. and as you add more and more information, will be your schematic and reference.

=====================

blink some LED's, use switches,
read about blink-without-delay and also debounce

write as much code as you can, based on your outline,.
test it.

at that point, you will have questions we can answer.
it seems right now, you need to learn how to make a program.

this should be pretty quick.

dave-in-nj:
there are typically 3 steps

first, write down your sequence as you think it should be. make an outline.
use a pencil, leave lots of open lines.
re-do it as you find you have to change things around,

one thinks 'turn on light'
but that really means
extend arm
move finger
touch switch
move switch
remove finger
pull back arm
switch to change state
switch to close contacts
power to pass through switch
power to reach light
light to have the correct power
you have to think of EVERY step. nothing happens by magic.

miftakhul_huda:
if you do not mind please give me a reference. thank you

what board do you have now ?
open the Arduino software.
look under examples. try them out.
you needs some switches, wire, resistors, LED's etc.
once you start to figure out how to light an LED, and use a switch, things will make more sense.

dave-in-nj:
what board do you have now ?
open the Arduino software.
look under examples. try them out.
you needs some switches, wire, resistors, LED's etc.
once you start to figure out how to light an LED, and use a switch, things will make more sense.

arduino uno R3
yes, sir
I will learn. tomorrow after I understood, I will describe my project and if I have trouble, please help me. thanks

The best way to implement these tasks is a state machine. The attached state diagram represents a fully scalable solution not bound to any number of floors.
The corresponding code is written using my state machine library

#include <SM.h>
SM elevator(checkBtn);

const int halleffect1 = 8;   //halleffect 1 is attached to pin 8
const int spst1 = 6;         //activate SPST1 coil 
const int spst2 = 7;         //activate SPST2 coil

byte regBtns;//register button presses
byte pos;//indicate actual floor postion
byte mask;
enum dir{down, up} currDir;//hold curretn direction for checking and moving

void setup() {
  //set outputs
  pinMode(spst1, OUTPUT);
  pinMode(spst2, OUTPUT);

  //begin serial comm.
  Serial.begin(115200);
  
  //send elevatot to first floor
  motorDown();
  while(!digitalRead(halleffect1));//wait for first floor
  motorStop();
}//setup()

void loop(){
  regBtns |= (PORTD>>2)&0xf;//register button press
  pos = (PORTB>>(halleffect1-8))&0xf;//read postion sensors
  EXEC(elevator);//run statemachine
}//loop()

State checkBtn(){
  if(currDir==down){//check downward from current pos
    mask = (pos>>1)|(pos>>2)|(pos>>3);//set mask to all lower positions
    if(regBtns&mask){//there are registered buttons below current position
      motorDown();//start moving downward
      elevator.Set(moveDir);
    }//if(regBtns&mask)
    else currDir = up;//no registerd buttons, change direction
  }else{//check upward from current position
    mask = ((pos<<1)|(pos<<2)|(pos<<3))&0xf;//set mask to all higher positions
    if(regBtns&mask){//there are registered buttons above current position
      motorUp();//start moving upward
      elevator.Set(moveDir);
    }//if(regBtns&mask)
    else currDir = down;//no registerd buttons, change direction    
  }//if(currDir==down)else
}//checkBtn()

State moveDir(){
  if(regBtns&pos){//elevator has reached a desired position
     motorStop();
     regBtns &= ~pos;//unregister position
     elevator.Set(stopMove);
  }//if(position reached)
}//moveDir()

State stopMove(){
  if(elevator.Timeout(1000)) elevator.Set(checkBtn);
}//stopMove()

//run motor in one direction
void motorUp() {  
  //code for motor commands
}//motorUp()

//run motor in opposite direction
void motorDown() {  
 //code for motor commands
}//motordown()

//stop motor
void motorStop() {
  //code for motor commands
}//motorstop

elevator state digram.png