How to modify 3A PWM Motor Speed controller with Arduino

Project Video
Project Details

This code is for video instruction to modify the DC 6V 12V 24V 28V 3A PWM module and control it using Arduino. Please watch the video instruction to understand it fully.

Project Code


/*
 * Modify 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 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 integer value representing % from 0-100
 * @return will return 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 integer value representing  from 0-255
 * @return will return value from 0 to 255
 * Written bh Ahmad Shamshiri for robojax.com
 * on July 30, 2019 in Ajax, Ontario, Canada
 */
int pwmToPercent(int p)
{
 return map(p, 0,255,0,100); 
}