Review of XY-GMOS 10A MOSFET Motor Driver and High-Low Trigger Switch Module
This can be used as a 10A high or low trigger switch; it works with 4V to 60V. Or you can control the speed of a DC motor with 10A power using PWM.
329-Other Resources
语言: C++
/*
* This Arduino Control Speed DC motor and START/STOP is using a push button
* using XY-GMOS Mosfet Speed Switch Module
*
* Watch Video instruction for this code:https://youtu.be/El5Dd51HBG8
*
* Full explanation of this code and wiring diagram is available at
* my Arduino Course at Udemy.com here: http://robojax.com/L/?id=62
* Written by Ahmad Shamshiri on May 31, 2020 at 17:49 in Ajax, Ontario, Canada
* in Ajax, Ontario, Canada. www.robojax.com
*
* Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in a structured course with all material, wiring diagrams, and libraries
all in one place. Purchase My course on Udemy.com http://robojax.com/L/?id=62
If you found this tutorial helpful, please support me so I can continue creating
content like this.
or make a donation using PayPal http://robojax.com/L/?id=64
* * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been downloaded from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const int POT_PIN =A0;//can change
const int MOTOR_OUT_PIN = 3;
const int START_STOP_PIN=2;
const int SPEED_MAX = 100;// in %
const int SPEED_MIN = 0;//in %
const int STOP=0;
const int RUN=1;
int motorState=RUN;//
int motorSpeed = 0;//between 0 to 100%.
void pushButton();
void setup() {
//Robojax XY-GMOS MOSFET Motor driver code
Serial.begin(9600);
Serial.println("Robojax XY-GMOS Motor, Arduino");
pinMode(START_STOP_PIN, INPUT_PULLUP);
pinMode(MOTOR_OUT_PIN, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
pushButton();
int potValue =analogRead(POT_PIN);
int speedPercent = map(potValue, 0, 1023, 0, 100);
Serial.print("speedPercent: "); Serial.println(speedPercent);
if(motorState ==RUN)
{
motorControl(speedPercent);
}else{
stopMotor();
}
delay(500);
//Robojax XY-GMOS MOSFET Motor driver code
}//loop end
/*
* motorControl(int s)
* @brief controls the motor with the value s
* @param return nothing
* @param "type" is character
* on May 08, 2020 at 02:36 in Ajax, Ontario, Canada
*/
void motorControl(int s)
{
//Robojax XY-GMOS MOSFET Motor driver code
s = map(s, SPEED_MIN, SPEED_MAX, 0, 255);
Serial.print("Speed: "); Serial.println(s);
analogWrite(MOTOR_OUT_PIN, s);
}//motorControl
/*
* stopMotor()
* @brief stops the motor
* @param return nothing
* @param
* on May 08, 2020 at 02:36 in Ajax, Ontario, Canada
*/
void stopMotor(){
//Robojax XY-GMOS MOSFET Motor driver code
analogWrite( MOTOR_OUT_PIN, 0);
Serial.println("STOPPED");
}//stopMotor()
/*
* pushButton()
* @brief reads the push button
* @param return nothing
* @param
* on May 08, 2020 at 02:36 in Ajax, Ontario, Canada
*/
void pushButton()
{
//Robojax XY-GMOS MOSFET Motor driver code
if(digitalRead(START_STOP_PIN) ==LOW)
{
motorState =!motorState;
delay(100);
}
}//pushButton()
资源与参考
-
外部
-
外部EL817 Optocoupler datasheet (PDF)everlight.com
-
外部MT3608 2A Step-Up Converter Datasheet (PDF)olimex.com
-
外部
文件📁
没有可用的文件。