Arduino code

Hello everyone,

We have a project thesis about a train (in scale modal!) who has to help wheelchair users and passengers with heavy luggage. We need to make 2 seperate doors (in the doorway where the passengers can enter the train) that can be used in 2 ways:

1: If a normal passenger wants to enter the train, he pushes on the first button. Then the 2 seperate doors have to open 90° in the train so the passengers can enter the train. The doors need to stay open for 15 seconds and then automatically close again/come together again (delay 15sec).

2: If a wheelchair user or a passenger with heavy luggage wants to enter the train, he pushes the second button. Then the 2 seperate doors have to open (tilt forward) up to the platform. The doors need to stay 25 seconds down and then close again (delay 25sec).

For both of these actions we use 2 little servo/steppermotors, but we can't find a correct code. Could somebody help us out of trouble?

Thanks a lot! :slight_smile:
Gilles_Vandamme

Nobody will find that code. It has to be written.
As You have not decided what motor You will use, that code can't be written.
What is the scale of the train? What voltage is available? Specifications please.....

the scale of the train doesn't matter i think, we use a basic arduino UNO and a breadbord (24V and less)
We will use a servo motor.

We just need a code to make it work how it used to...

do have any idea for a sketch designed ?

Well, i thought of a loop function that functions in the 2 ways given in the first post.
when pushing the first button, the servo motors have to turn 90°, like the doors from an elevator but then they turn inside the train.
when pushing the second button the servo motor above the doorway has to turn 107° because our platform can not have a bigger angle then 17° to step on it.

both functions need to have a delay: function 1 (15 seconds) and function 2 (25 seconds)
our servo motors work on the 5V used from the arduino UNO output.
the code is the only thing we need

Wel, if you are familar in coding in C than design the functions for input, processing and output like
button(), timer() and turnServo().
You shall keep in mind to design a FSM to do some jobs by the o.m. functions in "parallel".

i know i can use thos inputs but my coding is not that good and it has been a while since i wroted a code...
i just need a little more help

let´s take a look and show your sketch

gilles_vandamme:
i know i can use thos inputs but my coding is not that good and it has been a while since i wroted a code...
i just need a little more help

For a little more help make an attempt and then post that code saying what works and what doesn't. Then we'll have something to help WITH.

OTOH if "a little help" means you want it all done for you then try the Gigs and Collaborations forum and be prepared to pay someone to a job for you.

Steve

gilles_vandamme:
Hello everyone,

We have a project thesis about a train (in scale modal!) who has to help wheelchair users and passengers with heavy luggage. We need to make 2 seperate doors (in the doorway where the passengers can enter the train) that can be used in 2 ways:

For both of these actions we use 2 little servo/steppermotors, but we can't find a correct code. Could somebody help us out of trouble?

Thanks a lot! :slight_smile:
Gilles_Vandamme

Hi,
Project Thesis means you have to learn and show how and what you learned.
Just getting the correct code will not do or prove that.
Can you please tell us your electronics, programming, arduino, hardware experience?
For what course is this for?
Have you got on campus lecturers, tutors that can help you, that is what they are for.
In fact if they see and hear you asking questions and advice, your thesis may be better appreciated.
Tom... :slight_smile:

Hello,
and don´t forget to add a third input button for "emergency shut down" to your Project Thesis.
That will bring extra points :slight_smile:

we use 2 servo motors, we have an available 24V in our Arduino and a 5V output voltage from our arduino, the scale doesn’t matter only the doors need to do their work.
Gilles

Four weeks later and still no code for us to help with?

Where in your Arduino do you have 24V available?

Steve

Hi,

Please read the post at the start of any forum , entitled “How to use this Forum”.
OR

Then look down to “code problems” about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

We need to see your code?
We need to see your circuit diagram?

Have you got resources on campus to help with your coding?

Thanks… Tom… :grinning: :+1: :coffee: :australia:

our arduino works on 24V that’s what i was supposed to say

#include <Servo.h>

// constants won’t change
const int BUTTON_PIN = 7; // Arduino pin connected to button’s pin
const int SERVO_PIN = 9; // Arduino pin connected to servo motor’s pin

Servo servo; // create servo object to control a servo

// variables will change:
int angle = 0; // the current angle of servo motor
int lastButtonState; // the previous state of button
int currentButtonState; // the current state of button

void setup() {
Serial.begin(9600); // initialize serial
pinMode(BUTTON_PIN, INPUT_PULLUP); // set arduino pin to input pull-up mode
servo.attach(SERVO_PIN); // attaches the servo on pin 9 to the servo object

servo.write(angle);
currentButtonState = digitalRead(BUTTON_PIN);
}

void loop() {
lastButtonState = currentButtonState; // save the last state
currentButtonState = digitalRead(BUTTON_PIN); // read new state

if(lastButtonState == HIGH && currentButtonState == LOW) {
Serial.println(“The button is pressed”);

// change angle of servo motor
if(angle == 0)
  angle = 90;
 else
if(angle == 90)
  angle = 0;

// control servo motor arccoding to the angle
servo.write(angle);

}
}

i found this code but it needs to get a little change, if i push the button it turns 90 degrees, but then it has to wait 10sec before turning back to its normal position. I couldn’t find this yet…
we also need another piece of code to let our servo motor turn 5 360° by pushing a single button.
thx

Gilles

That is no usual Arduino then! :astonished:

its an arduino uno and that’s between 7 and 12 volt

But 24V isn’t between 7V and 12V so I still have no idea what the 24V has to do with anything.

And a normal servo will only turn around 180 degrees so whatever " turn 5 360°" means a standard servo won’t do it. Also you say you have 2 servos but your code only has one. What happened to the other one?

Steve

there is no 24V i typed wrong, ther is a 7-12V available.
then we’ll need a stepper motor, the code that i’ve made was only for our doors to turn 90°, the other piece of code where it has to turn 5 360° i didn’t make yet bcs it just won’t work with a servo, we’ll use a stepper motor for that (also need a code for that