Help! I have no Arduino experience beyond the simple "blink the LED" stuff. I have been tasked to create a simulation for a fake elevator for a haunted house (we do it for free) (push a button, light comes on, dial moves..." So basically what I need is-
Push button to start
LED turns on
(optional- relay to trigger sound effect)
start stepper motor to move from position A to position B (I can adjust settings for the actual positions)
relay to trigger a bell "ding"
LED turns off
pause say 30 seconds
reset stepper motor to position A
reset for next button push
I know this is a lot to ask, but I appreciate any assistance you can give!
Stepper vs servo depends on a number of factors. But there are other choices if you only need to move between two points: DC motors and solenoids come to mind.
How far does it have to move? How fast? How much weight is it moving?
Are you looking for code help or for someone to write it for you?
Hey,i belive the push button has to be pulled up check this link
btw i'm not a programmer but try this code
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
int button = 2; // The button will be on Pin 2
int led = 4; // Led will be on Pin 4
int relay = 5; // Relay will be on Pin 5
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
pinMode(pos, OUTPUT);
pinMode(button, INPUT);
pinMode(led, OUTPUT);
digitalWrite (led, LOW);
}
void loop()
{
if (digitalRead(button) == LOW)
digitalWrite(led, HIGH);
for(pos = 0; pos < 90; pos += 90) // goes from 0 degrees to 90 degrees
{ // in steps of degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(2000);
digitalWrite(relay, HIGH); //Turn on relay for the Bell
delay(1000); // wait 1 sec to turn off Bell
digitalWrite(relay, LOW); //Turn off relay for the Bell
digitalWrite(led, LOW);
delay (30000); //delay 30 seconds to return to home position and wait for next push
for(pos = 90; pos>=90; pos-=90) // goes from 90 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(50); // waits 50ms for the servo to reach the position
}
// waits 1s for the servo to reach the position
}
}
Unfortunately, i have neither the Arduino experience, nor the time to to totally write the code from scratch. I could adjust parameters for what I need to do, but that's about it at this time.
Since we need to simulate the slow movement of an old fashion elevator floor indicator, stepper or servo seem to the logical choices.
cedarlakeinstruments:
Stepper vs servo depends on a number of factors. But there are other choices if you only need to move between two points: DC motors and solenoids come to mind.
How far does it have to move? How fast? How much weight is it moving?
Are you looking for code help or for someone to write it for you?