Go Down

Topic: Need help with what is probably a simple project, willing to pay. (Read 656 times) previous topic - next topic


I am working on a project and want to integrate Arduino. I have never used it before but want to learn. I don't have time on this project though because of a tight deadline. So, if someone can help me with both the hardware/circuitry and software parts I will pay you. I'm sure this is a simple problem but...again, no time to study and experiment.

I need an arcade type momentary push button to turn on two different motors, both 125 volt, for a different period of time for each and then turn off until the next time the button is pushed. So, a person pushes the button, releases x amount of time later (it's an exhibit - people will be pushing it in every way you can imagine). When they push, both motors turn on at the same time and then one runs for 10 seconds and the other runs for 12 seconds. Then they both turn off and stay off until the button is pushed again, so there is no repetition.

Thank you .


That 125V is AC I suppose. Best way to switch that is with a relay, get a relay board for that. Make sure your relays can easily handle the current of your motors.

Button: wired between GND and the input pin.

This code should do what you want. It's indeed really simple.
Code: [Select]

#define MOTOR_1_PIN 5
#define MOTOR_1_ON_TIME 10000

#define MOTOR_2_PIN 6
#define MOTOR_2_ON_TIME 12000

#define OFF_TIME 2000

#define BUTTON_PIN 7

void setup() {
  pinMode(MOTOR_1_PIN, OUTPUT);
  pinMode(MOTOR_2_PIN, OUTPUT);


unsigned long startTime;
unsigned long stopTime;
bool motor1Running;
bool motor2Running;
void loop() {
  if (digitalRead(BUTTON_PIN) == LOW &&
      motor1Running == false && motor2Running == false &&
      millis() - stopTime > OFF_TIME) {
    startTime = millis();
    digitalWrite(MOTOR_1_PIN, HIGH);
    motor1Running = true;
    digitalWrite(MOTOR_2_PIN, HIGH);
    motor2Running = true;

  if (motor1Running) {
    if (startTime - millis() > MOTOR_1_ON_TIME) {
      digitalWrite(MOTOR_1_PIN, LOW);
      motor1Running = false;
      stopTime = millis();

  if (motor2Running) {
    if (startTime - millis() > MOTOR_2_ON_TIME) {
      digitalWrite(MOTOR_2_PIN, LOW);
      motor1Running = false;
      stopTime = millis();

Set the required pins, the times in milliseconds the motors have to be on (it doesn't matter which one is the shorter of the two - whatever works for you), and the time in milliseconds before they can be switched on again.

An ATtiny25 can handle this just fine, an Arduino is a bit overkill :-) I'll send you my PayPal by PM (don't want to post my e-mail address here), donations are welcome.

For your arduino: get a mini or micro, so you can solder all the wires. Don't use connectors, solder everything. Same for the power supply: a USB phone charger will do just fine, but make sure everything is soldered properly. The vibrations of people hitting that button will over time make your connections come loose.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


The above code is missing a crutial element. Push button debouncing.


No need to debounce in this situation, as any subsequent presses are ignored anyway. You're not counting presses, just checking whether there's a press and act on it.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up