variator de turatie PWM pt motor DC

am cautat o schema simpla de variator PWM, pt un strung cu un motor DC.
am adaptat un pic codul pt ca eu am varianta de shield cu display si butoane. si se conflictau cateva intrari-iesiri.

aici e codul original: https://www.engineersgarage.com/contributions/arduino-based-dc-motor-speed-controller/

aici gasiti pinii pt shield-ul display cu butoane: https://wiki.dfrobot.com/LCD_KeyPad_Shield_For_Arduino_SKU__DFR0009

mai jos este codul meu adaptat…
hai ca te descurci tu, nu e foarte complicat… 🙂

 to do: https://dronebotworkshop.com/dc-gearmotors-pwm/ and also, to do: https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM

//Program to

#include

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

#define potpin A5

#define motor_pin 10

int set_speed,motor_speed,disp_speed;

void setup()

{

   lcd.begin(16, 2); // initialize LCD as 16×2

   lcd.setCursor(0,0); // display message in 1st and 2nd line

   lcd.print(“Set speed: “);

   lcd.setCursor(0,1);

   lcd.print(“MotorSpeed:”);

}

void loop()

{

    int set_speed = analogRead(potpin); // take input from pot

    lcd.setCursor(12,0);

    lcd.print(set_speed/10); // display set speed in %

    lcd.print(‘%’);

    motor_speed = set_speed/4; // set motor speed as PWM width

    analogWrite(motor_pin,motor_speed);

    disp_speed = (motor_speed*100)/255; // display motor speed(PWM width) in %

    lcd.setCursor(12,1);

    lcd.print(disp_speed);

    lcd.print(‘%’);

    delay(200); // delay for 0.2 sec

 }

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Rain Viewer