Controlling a 5A DC Motor with an Arduino (Modified Module)
This code is for video instructions to modify the DC 6V 12V 24V 28V 3A PWM module and control it using Arduino. Please watch the video instructions to understand it fully.
221-How to modify and use Control 7833 12V-36V 3A Pulse Width Modulator PWM DC motor speed controller with Arduino
语言: C++
/*
* Modify a 7833 PWM 5A module to control with Arduino
* Modify the "12V-36V 3A Pulse Width Modulator PWM DC Motor Speed Controller Control Switch"
*
*
* Written by Ahmad Shamshiri
* on Saturday, July 27, 2019 at 18:23
* in Ajax, Ontario, Canada
* www.Robojax.com
* Watch the video instruction: https://youtu.be/en-SJookvjo
* See the module on eBay https://www.ebay.ca/sch/i.html?&_nkw=12V-36V+Pulse+Width+PWM&_sacat=0
* or search for "12V-36V Pulse Width PWM"
*/
#define pwmPin 5
#define controlPin A0
void setup() {
pinMode(pwmPin,OUTPUT);
Serial.begin(9600);
}
void loop() {
int potValue = analogRead(controlPin);
int pwm =map(potValue, 0,1023, 0, 255);
//pwm = toPWM(0);
analogWrite(pwmPin,pwm);
Serial.print("PWM:");
Serial.print(pwm);
Serial.print(" it is:");
Serial.print(pwmToPercent(pwm));
Serial.println("%");
delay(500);
}
/*
* @brief converts % value from 0 to 100% to 0-255
* @param v is an integer value representing % from 0-100
* @return will return a value from 0 to 255
* Written by Ahmad Shamshiri for robojax.com
* on July 30, 2019 in Ajax, Ontario, Canada
*/
int toPWM(int v){
return map(v, 0,100,0,255);
}//
/*
* @brief converts Arduino PWM value which is 0 to 255 to 0-100%
* @param p is an integer value representing a value from 0-255
* @return will return a value from 0 to 255
* Written by Ahmad Shamshiri for robojax.com
* on July 30, 2019 in Ajax, Ontario, Canada
*/
int pwmToPercent(int p)
{
return map(p, 0,255,0,100);
}
资源与参考
-
外部12V-36V 3A 脉冲宽度调制 PWM 直流电机速度控制器的全面评测youtu.be
-
外部7833 MOSFET 数据表 (PDF)infineon.com
文件📁
没有可用的文件。