Advertisement
RuiViana

Controle_DC_Motor

Nov 25th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. //Oscilador controlado por PWM com tela LCD
  2. //Projeto e programação: Thiago Lima
  3. //24-11-2015 09:00
  4.  
  5. #include <LiquidCrystal.h>
  6.  
  7. int motor=6;
  8. int potenciometro=0;
  9. int valor;
  10. int velocidad_motor;
  11. int NewValor;
  12.  
  13. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  14.  
  15. void setup()
  16. {
  17. lcd.begin(16,2);
  18. pinMode(motor,OUTPUT);
  19. }
  20. void loop()
  21. {
  22. lcd.setCursor(3,0);
  23. lcd.print("-=KESTRA=-");
  24. valor=analogRead(potenciometro);
  25. NewValor = map (valor,0,1023,1023,0);
  26. velocidad_motor=valor/5;
  27. analogWrite(motor,velocidad_motor);
  28.  
  29. lcd.setCursor(0,1);
  30. lcd.print("KST 030");
  31. lcd.setCursor(19,1);
  32. lcd.print(valor);
  33. lcd.setCursor(8,1);
  34. lcd.print("VEL:");
  35. lcd.setCursor(12,1);
  36. lcd.print(NewValor/5);
  37. // lcd.print(velocidad_motor);
  38. delay(1200);
  39. lcd.clear();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement