c_cpp ArduinoLibfürL298Schrittmotor-Treiber-IC.Vorwärts,Rückwärts,langsames Anfa

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp ArduinoLibfürL298Schrittmotor-Treiber-IC.Vorwärts,Rückwärts,langsames Anfa相关的知识,希望对你有一定的参考价值。

int motor1Front = 3;// defines motor1Front as connected to pin 5
int motor1Back  = 5;// defines motor1Back as connected to pin 6
int motor2Front = 6;// defines motor2Front as connected to pin 7
int motor2Back  = 9;// defines motor2Back as connected to pin 8
void engineStart(unsigned dir);
void engineStop(unsigned dir);

void setup ()
{
  pinMode (motor1Front, OUTPUT);// initialises motor1Front as output
  pinMode (motor1Back, OUTPUT);// initialises motor1Front as output
  pinMode (motor2Front, OUTPUT);// initialises motor1Front as output
  pinMode (motor2Back, OUTPUT);// initialises motor1Front as output
}



void engineStart(unsigned dir) {
  switch(dir) {
    case 'front':
      for (int i=0; i<=255; i++) //accelerate motor from 0 to 255
      {
         analogWrite (motor1Front, i);
         analogWrite (motor2Front, i);
         delay (10);
      }
      break;
    case 'back':
      for (int i=0; i<=255; i++) //accelerate motor from 0 to 255
      {
         analogWrite (motor1Back, i);
         analogWrite (motor2Back, i);
         delay (10);
      }
      break;
  }
}

void engineStop(unsigned dir) {
    switch(dir) {
    case 'front':
      for (int i=255; i>=0; i--) // Decrease speed from 255 to 0
      {
         analogWrite (motor1Front, i);
         analogWrite (motor2Front, i);
         delay (10);
      }
      break;
    case 'back':
      for (int i=255; i>=0; i--) // Decrease speed from 255 to 0
      {
         analogWrite (motor1Back, i);
         analogWrite (motor2Back, i);
         delay (10);
      }
      break;
  }
}

void engineSpeedCorrect(int speedValue) {

}

void loop ()
{
  // usage:
  engineStart('front');
  delay (3000);
  engineStop('front');
  engineStart('back');
  delay (3000);
  engineStop('back');
}

以上是关于c_cpp ArduinoLibfürL298Schrittmotor-Treiber-IC.Vorwärts,Rückwärts,langsames Anfa的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp Birüniversitedeöğrencilerinortalamaları50veüzerindeisederstenbaşarılısayılmakta

c_cpp Hipotenus'u 500 birime kadar olandiküçgenlerin,kenaruzunluklarınıgösterenbi

c_cpp klavyeden sizeyaşbilgisiveriliyor。 Siz de bubilgiyegöre,şayetyaş18'denküç&#

c_cpp Üçbasamaklırakamlarıbirbirindenfarklıtümsayılarıekrandagösterenvebu kurala

csharp Bir boyutlu dizidekienküçükelemanıveenbüyükelemanıbulanprogramıyazın

css AktiveCheckboxüberprüfen