How to drive this motor by Arduino

djsfantasi

Joined Apr 11, 2010
9,163
You should be able to use a 5V supply without going to a battery.
Max.
A better choice is a 9V DC supply. The Arduino power jack can accept up to 12V, but running at the maximum will heat up the onboard regulator. The DC power supplies for Arduino from several suppliers, including Arduino, are typically 9V.

You’ve paid for the voltage regulation circuitry when you’ve purchased an Arduino. No need to design and pay for your own. As far as the 5V relay, even when the Arduino is powered by 9 or 12V, it’s outputs are 5V
 

Thread Starter

LAOADAM

Joined Nov 21, 2018
879
You should be able to use a 5V supply without going to a battery.
Max.
Thanks.
I'm using a dc power supply which has 12v, 5v. I used 12v to Arduino, 5 v to relay. but they all from the same power line of 110vac. The reason I try to use battery is isolate the Arduino.
Best
 

Thread Starter

LAOADAM

Joined Nov 21, 2018
879
A better choice is a 9V DC supply. The Arduino power jack can accept up to 12V, but running at the maximum will heat up the onboard regulator. The DC power supplies for Arduino from several suppliers, including Arduino, are typically 9V.

You’ve paid for the voltage regulation circuitry when you’ve purchased an Arduino. No need to design and pay for your own. As far as the 5V relay, even when the Arduino is powered by 9 or 12V, it’s outputs are 5V
Thanks.
Yes, its a good suggestion to input Arduino a 9V instead of 12V. I'll use a 7809 to step down it.
Best
 

Thread Starter

LAOADAM

Joined Nov 21, 2018
879
Thanks.
Yes, its a good suggestion to input Arduino a 9V instead of 12V. I'll use a 7809 to step down it.
Best
Thanks.
I just tested use a 9V battery to the Arduino without a common ground, the machine doesn't run. I used 5Vdc to the relays, and common ground. the motors just turn one turn, can not continue running, don't know why?
 

slackguy

Joined Feb 11, 2016
76
This sounds stupid, but what I see is a a motor having an old radio control receiver attached to it. Had you the paired radio control and power attached it should work, if it isn't broken. I suggest NOT connecting it to an ardiuno except by optical coupling / isolation, since you might damage your ardiuno. You would replace the pots of the radio controller if you had that controller - but it's likely a layered circuit board: so you need the whole diagram and to build one (or buy a digital one, ie, a drone that is hackable). There are things more worth your time in my opinion than trying to reverse engineer a small motor from china. What is your goal again, in full?
 

Thread Starter

LAOADAM

Joined Nov 21, 2018
879
Thanks.
I just tested use a 9V battery to the Arduino without a common ground, the machine doesn't run. I used 5Vdc to the relays, and common ground. the motors just turn one turn, can not continue running, don't know why?
Thanks.
It's really sounds funny. Original I was try to control the motor by Arduino like the topic says, I got the motor running, but can't running by Arduino controlled. I used a 4x4 button matrix, and coded the Arduino to run the motor when '0' pressed, the result is the motor just run one circle or few circles when the '0' pressed, not as expected continually run.

I was guess may be the Electromagnetic interference? and used 9V battery to Arduino and 5V to relays, nothing better.

I know it may no worth to reuse the motors, my purpose is to know how can the Arduino control the 110V AC motor.

I attached the code, may make things easy.

Code:
// [REF1] add button matrix ............................................. DOWN
#include <Keypad.h>
const byte numRows = 4; //number of rows on the keypad
const byte numCols = 4; //number of columns on the keypad

//keymap defines the key pressed according to the row and columns just as appears on the keypad
char keymap[numRows][numCols] =
{
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

// byte rowPins[numRows] = {A2, A3, A4, A5}; //Rows 0 to 3
// byte colPins[numCols] = {12, 13, A0, A1}; //Columns 0 to 3

byte rowPins[numRows] = {12, 13, A0, A1}; //Rows 0 to 3
byte colPins[numCols] = {A2, A3, A4, A5}; //Columns 0 to 3


Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

const int ACMUDP = 2;   // '1' relay DCMotorUD positive
const int ACMUDN = 3;   // 'A' relay DCMotorUD negetive
const int ACMBELTP = 4;   // '4' relay DCMotorUD positive
const int ACMBELTN = 5;   // 'B'  relay DCMotorUD negetive
const int ACMPICKP = 8;   // '7' relay DCMotorLR positive
const int ACMPICKN = 9;   // 'C' relay DCMotorLR negetive
const int ACMSMEARP = 10;   // '*' relay DCMotorFS positive
const int ACMSMEARN = 11;   // 'D' relay DCMotorFS
const int ACMBUMP = 6;   // '2' relay DCMotorFS positive
const int ACMSTH = 7;   //  '3' ???????????????????????????????

int ACMotors[] = {ACMUDP, ACMUDN, ACMBELTP, ACMBELTN, ACMPICKP, ACMPICKN, ACMSMEARP, ACMSMEARN, ACMBUMP, ACMSTH};
//// 10 total used Pin20 ~ Pin29

int Biaoji = 0;

boolean running = false;

void setup() {
  Serial.begin(9600);

  for (int i = 0; i < 10; i++) {
    pinMode(ACMotors[i], OUTPUT);  //// rowPins[numRows] = {A8, A9, A10, A11};
    digitalWrite(ACMotors[i], HIGH);
  }


  for (int i = 0; i < 4; i++) {
    pinMode(rowPins[i], INPUT_PULLUP);  //// rowPins[numRows] = {A8, A9, A10, A11};
    digitalWrite(rowPins[i], LOW);
    Serial.println (rowPins[i]);  // print: 61, 60, 59, 58;  ('rowPins[i]') print: 26973, 26973, 26973,26973
  }

  for (int i = 0; i < 4; i++) {
    pinMode(colPins[i], OUTPUT);  //// colPins[numCols] = {A4, A5, A6, A7};
    digitalWrite(colPins[i], LOW);
    Serial.print (colPins[i]);
  }
}

void loop() { ////
  // RunningBeep();    //// beep once every 15 seconds as long as power ON
  // LswitchCheck();
  buttonMatrix();
  DoBiaoji();

  Serial.println("(boolean running");
  Serial.println(running);

  if  (running == true) {
    runMachine();
   // running = !running;

    Serial.println("(boolean running");
    Serial.println(running);
  }
}

void buttonMatrix()  //// tt button
{
  char keypressed = myKeypad.getKey();
  if (keypressed != NO_KEY)
  {
    Serial.println(keypressed);
  }

  Serial.println("Biaoji = ");
  Serial.println(Biaoji);

  if (keypressed == '0')  // BTSMRight;
  {
    running = true;
    // runMachine();
    delay(5);
  }

  if (keypressed == '#')  // BTSMLeft;
  {
    running = false;
    stopMachine();
  }

  if (keypressed == '1')  // BTSMRight;
  {
    digitalWrite(ACMUDP, LOW);
    delay(1000);
    digitalWrite(ACMUDP, HIGH);
  }

  if (keypressed == 'A')  // BTSMLeft;
  {
    digitalWrite(ACMUDN, LOW);
    delay(1000);
    digitalWrite(ACMUDN, HIGH);
  }

  if (keypressed == '4')  // BTSMLeft;
  {
    digitalWrite(ACMBELTP, LOW);
    delay(1000);
    digitalWrite(ACMBELTP, HIGH);
  }

  if (keypressed == 'B')  // BTSMDown;
  {
    digitalWrite(ACMBELTN, LOW);
    delay(1000);
    digitalWrite(ACMBELTN, HIGH);
  }

  if (keypressed == '7') // BTSMForward;
  {
    digitalWrite(ACMPICKP, LOW);
    delay(1000);
    digitalWrite(ACMPICKP, HIGH);
  }

  if (keypressed == 'C')  // BTSMBackward;
  {
    digitalWrite(ACMPICKN, LOW);
    delay(1000);
    digitalWrite(ACMPICKN, HIGH);
  }

  if (keypressed == '*')  // //  BTFLC button finger long close
  {
    digitalWrite(ACMSMEARP, LOW);
    delay(1000);
    digitalWrite(ACMSMEARP, HIGH);
  }

  if (keypressed == 'D')  //  BTFLO button finger long open
  {
    digitalWrite(ACMSMEARN, LOW);
    delay(1000);
    digitalWrite(ACMSMEARN, HIGH);
  }

  if (keypressed == '2')  // //  BTFLC button finger long close
  {
    digitalWrite(ACMBUMP, LOW);
    delay(1000);
    digitalWrite(ACMBUMP, HIGH);
  }

  if (keypressed == '3')  //  BTFLO button finger long open
  {
    digitalWrite(ACMSTH, LOW);
    delay(1000);
    digitalWrite(ACMSTH, HIGH);
  }
}

void runMachine() {

  //if (Biaoji == 8)


  digitalWrite(ACMUDP, LOW);
  delay(10);
  digitalWrite(ACMBELTP, LOW);
  delay(100);
  digitalWrite(ACMUDP, HIGH);
  digitalWrite(ACMBELTP, HIGH);
  digitalWrite(ACMPICKP, LOW);
  delay(10);
  digitalWrite(ACMSMEARP, LOW);

  delay(4000);

  digitalWrite(ACMSMEARP, HIGH);
  digitalWrite(ACMPICKP, HIGH);

  Serial.println("runMachine");
  Serial.println("Biaoji'0' = ");
  Serial.println(Biaoji);

  Serial.println("runMachine");
  Serial.println("Biaoji'0' = ");
  Serial.println(Biaoji);
}

void stopMachine() {

  digitalWrite(ACMUDP, HIGH);
  digitalWrite(ACMBELTP, HIGH);
  digitalWrite(ACMPICKP, HIGH);
  digitalWrite(ACMSMEARP, HIGH);

  Biaoji = 0;

}

void DoBiaoji() {
  if (Biaoji == 8) {
    runMachine();
  }
}
 

Reloadron

Joined Jan 15, 2015
7,517
You have a 120 VAC 50/60 Hz single phase AC motor. You have a 4x4 matrix keypad using likely an Arduino Uno. How are you interfacing your Arduino to your motor? Provide a drawing or schematic? The code snippet is written around controlling a DC motor.

If you want speed control of a motor like you have I suggest you read this article paying attention to the schematic and use of an SCR. Pretty much what I believe Max suggested at the beginning. Even that may only work moderate at best.

Again, post a schematic.

Ron
 

Thread Starter

LAOADAM

Joined Nov 21, 2018
879
You have a 120 VAC 50/60 Hz single phase AC motor. You have a 4x4 matrix keypad using likely an Arduino Uno. How are you interfacing your Arduino to your motor? Provide a drawing or schematic? The code snippet is written around controlling a DC motor.

If you want speed control of a motor like you have I suggest you read this article paying attention to the schematic and use of an SCR. Pretty much what I believe Max suggested at the beginning. Even that may only work moderate at best.

Again, post a schematic.

Ron
Thanks.
I just made a schematic for one motor attached.
What I used are relay group board that with a 5VDC input, I can't find it in Proteus.
I don't need speed control, just turning the motor forward and reverse for 4 motors at the different time controlled by Arduino UNO.
Best.
POST33.JPG
 
Last edited:

MisterBill2

Joined Jan 23, 2018
18,514
The first step is to verify that you can switch outputs on and off with the arduino board. But also you need to verify that the relay board is functioning correctly. But in the drawing I see not relay control circuit board, I see relays connected directly to the arduino outputs. Are those outputs even able to operate the relay? Are you able to measure the coil voltage of the relay while you try to operate it from your control program? The problem is probably in the software of the arduino, I can not help with that.
 
Last edited:

Thread Starter

LAOADAM

Joined Nov 21, 2018
879
The first step is to verify that you can switch outputs on and off with the arduino board. But also you need to verify that the relay board is functioning correctly. But in the drawing I see not relay control circuit board, I see relays connected directly to the arduino outputs. Are those outputs even able to operate the relay? Are you able to measure the coil voltage of the relay while you try to operate it from your control program? The problem is probably in the software of the arduino, I can not help with that.
Thanks.
The all unit works, the motors can run few circles some time.
I used relay group board module that with a 5VDC input, I can't find it in Proteus library to show, but the module be used lot of in my other projects.
best
 

djsfantasi

Joined Apr 11, 2010
9,163
The first step is to verify that you can switch outputs on and off with the arduino board. But also you need to verify that the relay board is functioning correctly. But in the drawing I see not relay control circuit board, I see relays connected directly to the arduino outputs. Are those outputs even able to operate the relay? Are you able to measure the coil voltage of the relay while you try to operate it from your control program? The problem is probably in the software of the arduino, I can not help with that.
We need to know the specifications of the relays, particularly the relay coils. Activation voltage, hold voltage, coil resistance. Or required current for the coil, which could be calculated for the former specifications.

If the coil requires more than 20mA, you can’t drive it directly from the Arduino. You will need a PNP transistor or P channel logic level MOSFET with a driver.

Or, I recommend placing V+ in common to the relay coils and switching ground. This is easier. Then, use an N channel logic level MOSFET to switch ground. Like a 2N7000.

Additionally, you’ll need a diode reverse biased connected across the relay coil. That is, the cathode would be connected to V+. Without this, the Arduino or MOSFET will be destroyed.

It would be useful if you posted your sketch (between code tags) so that we can see it.
 

Thread Starter

LAOADAM

Joined Nov 21, 2018
879
We need to know the specifications of the relays, particularly the relay coils. Activation voltage, hold voltage, coil resistance. Or required current for the coil, which could be calculated for the former specifications.

If the coil requires more than 20mA, you can’t drive it directly from the Arduino. You will need a PNP transistor or P channel logic level MOSFET with a driver.

Or, I recommend placing V+ in common to the relay coils and switching ground. This is easier. Then, use an N channel logic level MOSFET to switch ground. Like a 2N7000.

Additionally, you’ll need a diode reverse biased connected across the relay coil. That is, the cathode would be connected to V+. Without this, the Arduino or MOSFET will be destroyed.

It would be useful if you posted your sketch (between code tags) so that we can see it.
Thanks.
The relay modules used here from EBAY, picture attached, the relay used 5VDC power supply, Arduino used 12Vdc:
https://www.ebay.ca/itm/4-Channel-5...630353?hash=item3b2e3a1ad1:g:VIUAAOSwWk5csAb8

relays.JPG

the sketch:
Code:
// [REF1] add button matrix ............................................. DOWN
#include <Keypad.h>
const byte numRows = 4; //number of rows on the keypad
const byte numCols = 4; //number of columns on the keypad

//keymap defines the key pressed according to the row and columns just as appears on the keypad
char keymap[numRows][numCols] =
{
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

// byte rowPins[numRows] = {A2, A3, A4, A5}; //Rows 0 to 3
// byte colPins[numCols] = {12, 13, A0, A1}; //Columns 0 to 3

byte rowPins[numRows] = {12, 13, A0, A1}; //Rows 0 to 3
byte colPins[numCols] = {A2, A3, A4, A5}; //Columns 0 to 3

Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

// myKeypad.setHoldTime(1000);

const int ACMUDP = 2;   // '1' relay DCMotorUD positive
const int ACMUDN = 3;   // 'A' relay DCMotorUD negetive
const int ACMBELTP = 4;   // '4' relay DCMotorUD positive
const int ACMBELTN = 5;   // 'B'  relay DCMotorUD negetive
const int ACMPICKP = 8;   // '7' relay DCMotorLR positive
const int ACMPICKN = 9;   // 'C' relay DCMotorLR negetive
const int ACMSMEARP = 10;   // '*' relay DCMotorFS positive
const int ACMSMEARN = 11;   // 'D' relay DCMotorFS
const int ACMBUMP = 6;   // '2' relay DCMotorFS positive
const int ACMSTH = 7;   //  '3' ???????????????????????????????

int ACMotors[] = {ACMUDP, ACMUDN, ACMBELTP, ACMBELTN, ACMPICKP, ACMPICKN, ACMSMEARP, ACMSMEARN, ACMBUMP, ACMSTH};
//// 10 total used Pin20 ~ Pin29

int Biaoji = 0;

boolean running = false;

void setup() {
  Serial.begin(9600);

  for (int i = 0; i < 10; i++) {
    pinMode(ACMotors[i], OUTPUT);  //// rowPins[numRows] = {A8, A9, A10, A11};
    digitalWrite(ACMotors[i], HIGH);

  }


  for (int i = 0; i < 4; i++) {
    pinMode(rowPins[i], INPUT_PULLUP);  //// rowPins[numRows] = {A8, A9, A10, A11};
    digitalWrite(rowPins[i], LOW);
    Serial.println (rowPins[i]);  // print: 61, 60, 59, 58;  ('rowPins[i]') print: 26973, 26973, 26973,26973
  }

  for (int i = 0; i < 4; i++) {
    pinMode(colPins[i], OUTPUT);  //// colPins[numCols] = {A4, A5, A6, A7};
    digitalWrite(colPins[i], LOW);
    Serial.print (colPins[i]);
  }

  myKeypad.setHoldTime(3000);  //// https://forum.arduino.cc/index.php?topic=407946.0
  myKeypad.setDebounceTime(200);

  Serial.println("setup");
}

void loop() { ////
  // RunningBeep();    //// beep once every 15 seconds as long as power ON
  // LswitchCheck();
  buttonMatrix();
  // DoBiaoji();

  if  (running == true) {
    runMachine();
    // running = !running;

    Serial.println("running");
    Serial.println(running);
  }

  if  (running == false) {
    stopMachine();
    Serial.println("running");
    Serial.println(running);
  }
}

void buttonMatrix()  //// tt button
{
  char keypressed = myKeypad.getKey();
  if (keypressed != NO_KEY)
  {
    Serial.println(keypressed);
  }

  if (keypressed == '0')  // BTSMRight;
  {
    running = true;
    // runMachine();
    delay(5);
  }

  if (keypressed == '#')  // BTSMLeft;
  {
    stopMachine();
    running = false;
  }

  if (keypressed == '1')  // BTSMRight;
  {
    digitalWrite(ACMUDP, LOW);
    delay(1000);
    digitalWrite(ACMUDP, HIGH);
  }

  if (keypressed == 'A')  // BTSMLeft;
  {
    digitalWrite(ACMUDN, LOW);
    delay(1000);
    digitalWrite(ACMUDN, HIGH);
  }

  if (keypressed == '4')  // BTSMLeft;
  {
    digitalWrite(ACMBELTP, LOW);
    delay(1000);
    digitalWrite(ACMBELTP, HIGH);
  }

  if (keypressed == 'B')  // BTSMDown;
  {
    digitalWrite(ACMBELTN, LOW);
    delay(1000);
    digitalWrite(ACMBELTN, HIGH);
  }

  if (keypressed == '7') // BTSMForward;
  {
    digitalWrite(ACMPICKP, LOW);
    delay(1000);
    digitalWrite(ACMPICKP, HIGH);
  }

  if (keypressed == 'C')  // BTSMBackward;
  {
    digitalWrite(ACMPICKN, LOW);
    delay(1000);
    digitalWrite(ACMPICKN, HIGH);
  }

  if (keypressed == '*')  // //  BTFLC button finger long close
  {
    digitalWrite(ACMSMEARP, LOW);
    delay(1000);
    digitalWrite(ACMSMEARP, HIGH);
  }

  if (keypressed == 'D')  //  BTFLO button finger long open
  {
    digitalWrite(ACMSMEARN, LOW);
    delay(1000);
    digitalWrite(ACMSMEARN, HIGH);
  }

  if (keypressed == '2')  // //  BTFLC button finger long close
  {
    digitalWrite(ACMBUMP, LOW);
    delay(1000);
    digitalWrite(ACMBUMP, HIGH);
  }

  if (keypressed == '3')  //  BTFLO button finger long open
  {
    digitalWrite(ACMSTH, LOW);
    delay(1000);
    digitalWrite(ACMSTH, HIGH);
  }
}

void runMachine() {

  digitalWrite(ACMUDP, LOW);
  delay(10);
  digitalWrite(ACMBELTP, LOW);
  delay(100);
  digitalWrite(ACMUDP, HIGH);
  digitalWrite(ACMBELTP, HIGH);
  digitalWrite(ACMPICKP, LOW);
  delay(10);
  digitalWrite(ACMSMEARP, LOW);

  delay(5000);

  digitalWrite(ACMSMEARP, HIGH);
  digitalWrite(ACMPICKP, HIGH);
  delay(1000);

  Serial.println("runMachine");
}

void stopMachine() {

  digitalWrite(ACMUDP, HIGH);
  digitalWrite(ACMBELTP, HIGH);
  digitalWrite(ACMPICKP, HIGH);
  digitalWrite(ACMSMEARP, HIGH);

}
 
Last edited:

djsfantasi

Joined Apr 11, 2010
9,163
Thanks.
The relay modules used here from EBAY, picture attached:
https://www.ebay.ca/itm/4-Channel-5...630353?hash=item3b2e3a1ad1:g:VIUAAOSwWk5csAb8

View attachment 214896

the sketch:
Code:
// [REF1] add button matrix ............................................. DOWN
#include <Keypad.h>
const byte numRows = 4; //number of rows on the keypad
const byte numCols = 4; //number of columns on the keypad

//keymap defines the key pressed according to the row and columns just as appears on the keypad
char keymap[numRows][numCols] =
{
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

// byte rowPins[numRows] = {A2, A3, A4, A5}; //Rows 0 to 3
// byte colPins[numCols] = {12, 13, A0, A1}; //Columns 0 to 3

byte rowPins[numRows] = {12, 13, A0, A1}; //Rows 0 to 3
byte colPins[numCols] = {A2, A3, A4, A5}; //Columns 0 to 3

Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

// myKeypad.setHoldTime(1000);

const int ACMUDP = 2;   // '1' relay DCMotorUD positive
const int ACMUDN = 3;   // 'A' relay DCMotorUD negetive
const int ACMBELTP = 4;   // '4' relay DCMotorUD positive
const int ACMBELTN = 5;   // 'B'  relay DCMotorUD negetive
const int ACMPICKP = 8;   // '7' relay DCMotorLR positive
const int ACMPICKN = 9;   // 'C' relay DCMotorLR negetive
const int ACMSMEARP = 10;   // '*' relay DCMotorFS positive
const int ACMSMEARN = 11;   // 'D' relay DCMotorFS
const int ACMBUMP = 6;   // '2' relay DCMotorFS positive
const int ACMSTH = 7;   //  '3' ???????????????????????????????

int ACMotors[] = {ACMUDP, ACMUDN, ACMBELTP, ACMBELTN, ACMPICKP, ACMPICKN, ACMSMEARP, ACMSMEARN, ACMBUMP, ACMSTH};
//// 10 total used Pin20 ~ Pin29

int Biaoji = 0;

boolean running = false;

void setup() {
  Serial.begin(9600);

  for (int i = 0; i < 10; i++) {
    pinMode(ACMotors[i], OUTPUT);  //// rowPins[numRows] = {A8, A9, A10, A11};
    digitalWrite(ACMotors[i], HIGH);

  }


  for (int i = 0; i < 4; i++) {
    pinMode(rowPins[i], INPUT_PULLUP);  //// rowPins[numRows] = {A8, A9, A10, A11};
    digitalWrite(rowPins[i], LOW);
    Serial.println (rowPins[i]);  // print: 61, 60, 59, 58;  ('rowPins[i]') print: 26973, 26973, 26973,26973
  }

  for (int i = 0; i < 4; i++) {
    pinMode(colPins[i], OUTPUT);  //// colPins[numCols] = {A4, A5, A6, A7};
    digitalWrite(colPins[i], LOW);
    Serial.print (colPins[i]);
  }

  myKeypad.setHoldTime(3000);  //// https://forum.arduino.cc/index.php?topic=407946.0
  myKeypad.setDebounceTime(200);

  Serial.println("setup");
}

void loop() { ////
  // RunningBeep();    //// beep once every 15 seconds as long as power ON
  // LswitchCheck();
  buttonMatrix();
  // DoBiaoji();

  if  (running == true) {
    runMachine();
    // running = !running;

    Serial.println("running");
    Serial.println(running);
  }

  if  (running == false) {
    stopMachine();
    Serial.println("running");
    Serial.println(running);
  }
}

void buttonMatrix()  //// tt button
{
  char keypressed = myKeypad.getKey();
  if (keypressed != NO_KEY)
  {
    Serial.println(keypressed);
  }

  if (keypressed == '0')  // BTSMRight;
  {
    running = true;
    // runMachine();
    delay(5);
  }

  if (keypressed == '#')  // BTSMLeft;
  {
    stopMachine();
    running = false;
  }

  if (keypressed == '1')  // BTSMRight;
  {
    digitalWrite(ACMUDP, LOW);
    delay(1000);
    digitalWrite(ACMUDP, HIGH);
  }

  if (keypressed == 'A')  // BTSMLeft;
  {
    digitalWrite(ACMUDN, LOW);
    delay(1000);
    digitalWrite(ACMUDN, HIGH);
  }

  if (keypressed == '4')  // BTSMLeft;
  {
    digitalWrite(ACMBELTP, LOW);
    delay(1000);
    digitalWrite(ACMBELTP, HIGH);
  }

  if (keypressed == 'B')  // BTSMDown;
  {
    digitalWrite(ACMBELTN, LOW);
    delay(1000);
    digitalWrite(ACMBELTN, HIGH);
  }

  if (keypressed == '7') // BTSMForward;
  {
    digitalWrite(ACMPICKP, LOW);
    delay(1000);
    digitalWrite(ACMPICKP, HIGH);
  }

  if (keypressed == 'C')  // BTSMBackward;
  {
    digitalWrite(ACMPICKN, LOW);
    delay(1000);
    digitalWrite(ACMPICKN, HIGH);
  }

  if (keypressed == '*')  // //  BTFLC button finger long close
  {
    digitalWrite(ACMSMEARP, LOW);
    delay(1000);
    digitalWrite(ACMSMEARP, HIGH);
  }

  if (keypressed == 'D')  //  BTFLO button finger long open
  {
    digitalWrite(ACMSMEARN, LOW);
    delay(1000);
    digitalWrite(ACMSMEARN, HIGH);
  }

  if (keypressed == '2')  // //  BTFLC button finger long close
  {
    digitalWrite(ACMBUMP, LOW);
    delay(1000);
    digitalWrite(ACMBUMP, HIGH);
  }

  if (keypressed == '3')  //  BTFLO button finger long open
  {
    digitalWrite(ACMSTH, LOW);
    delay(1000);
    digitalWrite(ACMSTH, HIGH);
  }
}

void runMachine() {

  digitalWrite(ACMUDP, LOW);
  delay(10);
  digitalWrite(ACMBELTP, LOW);
  delay(100);
  digitalWrite(ACMUDP, HIGH);
  digitalWrite(ACMBELTP, HIGH);
  digitalWrite(ACMPICKP, LOW);
  delay(10);
  digitalWrite(ACMSMEARP, LOW);

  delay(5000);

  digitalWrite(ACMSMEARP, HIGH);
  digitalWrite(ACMPICKP, HIGH);
  delay(1000);

  Serial.println("runMachine");
}

void stopMachine() {

  digitalWrite(ACMUDP, HIGH);
  digitalWrite(ACMBELTP, HIGH);
  digitalWrite(ACMPICKP, HIGH);
  digitalWrite(ACMSMEARP, HIGH);

}
Oh! I didn’t understand you were using that module. Forget what I said. Everything I mentioned is likely included in the module. Your schematic likely didn’t represent the module well.

I’ll look at the code.
 
Top