计算机环境:ubuntu12.04,arduino IDE
硬件:
1,Arduino Mega2560
2,扩展板 Sensor Shield Module V5
3,L298N Dual H Bridge Stepper Motor Driver Controller Board Module
3 还有锂电池,和两个直流电机(改天再补上图片)
电路完成图的图(改天再补详细的连接):
-----------------------------------------------------------------------------------------------------------
测试代码:
//ARDUINO L298N
int pin1=8; int pin2=9; int speedpin1=11; int pin3=6; int pin4=7; int speedpin2=10; void setup() { pinMode(pin1,OUTPUT); pinMode(pin2,OUTPUT); pinMode(speedpin1,OUTPUT); pinMode(pin3,OUTPUT); pinMode(pin4,OUTPUT); pinMode(speedpin2,OUTPUT); } void loop() { digitalWrite(speedpin1,100); delay(2000); digitalWrite(pin1,LOW); digitalWrite(pin2,HIGH); digitalWrite(pin3,LOW); digitalWrite(pin4,HIGH); digitalWrite(speedpin2,100); delay(2000); digitalWrite(pin1,HIGH); digitalWrite(pin2,LOW); digitalWrite(pin3,HIGH); digitalWrite(pin4,LOW); digitalWrite(pin1,HIGH); digitalWrite(pin2,HIGH); digitalWrite(pin3,HIGH); digitalWrite(pin4, HIGH); delay(2000); } ---------------------------------------------------------------------------------------------------------------------------参考资料: