请问各位大神我该如何使电机反转啊?电机驱动板买哪个型号?怎样接线啊?求有做过电机正反转的大神帮忙。
现在电机可以正转,减速,停止,就是不可以反转。
遥控器可以控制电机正反转,如果做H桥的话,要买哪个型号的电机驱动板?
电调只有三个接口,- (负极) +(正极) 信号(pwm),该如何接线?
arduino 代码:
Servo duoji;
Servo motor;
int x=90;
int y=0;
char val; // Data received from the serial port
int ledPin = 13; // Set the pin to digital I/O 13
boolean ledState = LOW; //to toggle our LED
void setup()
{
pinMode(ledPin, OUTPUT); // Set pin as OUTPUT
//initialize serial communications at a 9600 baud rate
Serial.begin(9600);
establishContact(); // send a byte to establish contact until receiver responds
motor.attach(5);
duoji.attach(9);
}
void loop()
{
if (Serial.available() > 0) { // If data is available to read,
val = Serial.read(); // read it and store it in val
if(-1 != val) //if we get a 1
{
if('d'==val){
for( x=90;x<125;x+=3){}
duoji.write(x);
delay(20);
}
//delay(20);
if('s'==val){
x=90;
duoji.write(x);
}
if('a'==val){
for( x=90;x>55;x-=3){}
duoji.write(x);
delay(20);
}
if('j'==val)
{
y=100;
motor.write(y);
delay(15);
}
if('k'==val)
{
y=y-2;
if(y<=0)
{y=0;}
motor.write(y);
delay(15);
}
if('l'==val)
{
y=-115;
motor.write(y);
delay(15);
}
ledState = !ledState; //flip the ledState
digitalWrite(ledPin, ledState);
}
delay(100);
}
else {
Serial.println("Hello, world!"); //send back a hello world
delay(50);
}
}
void establishContact() {
while (Serial.available() <= 0) {
Serial.println("A"); // send a capital A
delay(300);
}
}
现在问题是:我按下L按键后,如何使电机反转?
大神快点出现吧!!
|