How to Modify a 3A PWM Motor Speed Controller with an Arduino
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.220-How to modify and use Control 7833 5A PWM motor speed controller with Arduino
语言: C++
++
/*
* Modify the 7833 PWM Module to control with Arduino
* Modify the "DC 6V 12V 24V 28V 3A PWM Speed controller"
*
*
* 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/EapP4BhlYb0
* See the module on Amazon http://bit.ly/3A-pwm-am
* See the module on eBay http://bit.ly/3A-PWM-eBay
* or search for "DC 6V 12V 24V 28V 3A PWM"
* Watch the full review video of this module: https://youtu.be/inUOVV0LnoQ
*/
#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);
}
资源与参考
-
外部1045肖特基二极管数据表(PDF)st.com
-
外部
文件📁
没有可用的文件。