please the program doesn't make break; (on proteus)
pease any suggestions
or could you help me making an alternative programming
I am New
elevator_destoooo.ino (1.6 KB)
please the program doesn't make break; (on proteus)
pease any suggestions
or could you help me making an alternative programming
I am New
elevator_destoooo.ino (1.6 KB)
please the program doesn't make break; (on proteus)
pease any suggestions
or could you help me making an alternative programming
I am New
elevator_destoooo.ino (1.6 KB)
A few problems ...
It would be easier for people here if you just paste your code into the forum (using Code tags - the # button) so that we don't have to waste time opening a file.
Your code is very poorly formatted so it is almost impossible to read. Use the autoformat button in the Arduino IDE.
Your code has no comments so I have no idea where the problem you mention might be located.
You haven't described what the program does and what you would like it to do.
People here will do a lot to help you, but you need to help us.
...R
A switch statement makes sense when there are three or more possible states. It does not when there are only two.
Random indenting
does not make
for readable code.
Given that there is an Auto Format
menu item on the Tools menu,
it is inexcusable that you
haven't used it.
You have some hardware that you haven't described.
The software does something that you haven't described.
You want it to do something that you haven't described.
So, no. No one can help you.
First of all thanks so much
this is an elevator's project of Building consist of 4 floors
distance between two floors is 1.5m
and its speed is 1m/s
the problem is it doesnt make a break
plz help me find the problem or tell me another way
and i will be so thankful
int one_UP =1; // first floor
int two_UP =2; // second floor
int three_UP = 3;// third floor
int four_up = 4;// forth floor
int Ground = 8; // ground
int Motor =9;
int Reverse = 10 ;
int state ;
int state1 ;
int state2 ;
int state3 ;
int state4 ;
void setup() {
pinMode(one_UP, INPUT);
pinMode(two_UP, INPUT);
pinMode(three_UP, INPUT);
pinMode(four_up, INPUT);
pinMode(Ground, INPUT);
pinMode(Motor, OUTPUT); //motor dir UP
pinMode(Reverse, OUTPUT); //motor Reverse
}
void loop()
{
state = digitalRead(one_UP);
switch (state){
case 0:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, LOW);
break;
case 1:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, HIGH);
delay(1500); // first floor 1.5 m from ground
digitalWrite(Motor, LOW);
delay(2500);
break;
}
state1 = digitalRead(two_UP);
switch (state1){
case 0:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, LOW);
break;
case 1:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, HIGH);
delay(3000);// second floor 3 m from ground
digitalWrite(Motor, LOW);
delay(2500);
break;
}
state2 = digitalRead(three_UP);
switch (state2){
case 0:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, LOW);
break;
case 1:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, HIGH);
delay(4500); // third floor 4.5 m from ground
digitalWrite(Motor, LOW);
delay(2500);
break;
}
state3 = digitalRead(four_up);
switch (state3){
case 0:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, LOW);
break;
case 1:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, HIGH);
delay(6000); // forth floor 6 m from ground
digitalWrite(Motor, LOW);
delay(2500);
break;
}
state4 = digitalRead(Ground);
switch (state4){
case 0:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, LOW);
break;
case 1:
digitalWrite(Reverse, HIGH);
digitalWrite(Motor, LOW);
delay(6000);
digitalWrite(Reverse, LOW);
delay(2500);
break;
}
}
First thing I would say is you are making your code much harder to read
and overly verbose by using switch-case where an if-statement is the natural
fit:
state = digitalRead(one_UP);
switch (state){
case 0:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, LOW);
break;
case 1:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, HIGH);
delay(1500);
digitalWrite(Motor, LOW);
delay(2500);
break;
}
can be much simpler:
digitalWrite(Reverse, LOW);
if (digitalRead(one_UP))
{
digitalWrite(Motor, HIGH);
delay(1500);
digitalWrite(Motor, LOW);
delay(2500);
}
else
{
digitalWrite(Motor, LOW);
}
so sorry iam new
so could you please tell me how it will works
i mean how to set the distance
and make it goes down
could you write it for me ... i am so sorry
i tried your way and when i press Button
motor starts make a delay and start again
i want it to run one time ... plz Help
this is an elevator's project of Building consist of 4 floors
distance between two floors is 1.5m
and its speed is 1m/s
the problem is it doesnt make a break
plz help me find the problem or tell me another way
and i will be so thankful
int one_UP =1; // first floor
int two_UP =2; // second floor
int three_UP = 3;// third floor
int four_up = 4;// forth floor
int Ground = 8; // ground
int Motor =9;
int Reverse = 10 ;
int state ;
int state1 ;
int state2 ;
int state3 ;
int state4 ;
void setup() {
pinMode(one_UP, INPUT);
pinMode(two_UP, INPUT);
pinMode(three_UP, INPUT);
pinMode(four_up, INPUT);
pinMode(Ground, INPUT);
pinMode(Motor, OUTPUT); //motor dir UP
pinMode(Reverse, OUTPUT); //motor Reverse
}
void loop()
{
state = digitalRead(one_UP);
switch (state){
case 0:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, LOW);
break;
case 1:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, HIGH);
delay(1500); // first floor 1.5 m from ground
digitalWrite(Motor, LOW);
delay(2500);
break;
}
state1 = digitalRead(two_UP);
switch (state1){
case 0:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, LOW);
break;
case 1:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, HIGH);
delay(3000);// second floor 3 m from ground
digitalWrite(Motor, LOW);
delay(2500);
break;
}
state2 = digitalRead(three_UP);
switch (state2){
case 0:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, LOW);
break;
case 1:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, HIGH);
delay(4500); // third floor 4.5 m from ground
digitalWrite(Motor, LOW);
delay(2500);
break;
}
state3 = digitalRead(four_up);
switch (state3){
case 0:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, LOW);
break;
case 1:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, HIGH);
delay(6000); // forth floor 6 m from ground
digitalWrite(Motor, LOW);
delay(2500);
break;
}
state4 = digitalRead(Ground);
switch (state4){
case 0:
digitalWrite(Reverse, LOW);
digitalWrite(Motor, LOW);
break;
case 1:
digitalWrite(Reverse, HIGH);
digitalWrite(Motor, LOW);
delay(6000);
digitalWrite(Reverse, LOW);
delay(2500);
break;
}
}
Help :~
Adding a reminder after two hours is a bit cheeky. After 48 hours would be OK.
Where did you get the code that you already have? If you wrote it yourself please go through it and write comments that explain what each section does (or is supposed to do) and then post the updated copy.
I don't understand what you mean when you say
it doesn't make a break
...R
I see delays, and delays are bad ]
Well, not that bad, but the Arduino is blind and deaf during an delay.
Can you make it more mathematical/abstract ?
I rename "ground level" to "level 0".
const int pinLevel0 = 8; // ground
const int pinLevel1 = 2; // second floor
const int pinLevel2 = 3; // third floor
const int pinLevel3 = 4; // forth floor
I can't continue, because I don't know what the code should do.
Are there buttons to press, or switches that active at a certain floor ?
How does the elevator know what to do ? Is there some special sequence ?
In your loop, first gather all the states, and after that decide what to do.
Did you try a test sketch for just the motor ?
Can you make the motor go in both directions and make it stop ?
this CODE is an elevator's project of Building consist of 4 floors
distance between two floors is 1.5m
and its speed IS 1M/S
well i control it using buttons
plz can u help me
desto:
plz can u help me
Have you read any of the replies you have received?
We can only help if you answer the questions and respond to the comments that have been made.
...R
desto, you started more than one topic, and I think a moderator merged some.
Now it is all very confusion, and we still don't know what your code is for. What is the function of the buttons and what should the elevator do. We have no idea. Do you even have an Arduino ? Can you make a photo of the elevator ?
Hi...............We are different types of elevators provider but i haven't any idea how to resolve this kind of programming elevators.
Gravityelevator:
Hi...............We are different types of elevators provider but i haven't any idea how to resolve this kind of programming elevators.
Describe clearly what you want to happen.
If you have any code that you have already tried post a copy. Please read the How To Use The Forum to see how to do it.
...R