Siin siis testitud lahendus:
Ja väga lihtne kood testimiseks
Ja väga lihtne kood testimiseks
const int motor1EnablePin = 5; const int motor1ForwardPin = 7; const int motor1ReversePin = 8; const int motor2EnablePin = 6; const int motor2ForwardPin = 12; const int motor2ReversePin = 13; void setupMotor(){ pinMode(motor1EnablePin, OUTPUT); pinMode(motor1ForwardPin, OUTPUT); pinMode(motor1ReversePin, OUTPUT); pinMode(motor2EnablePin, OUTPUT); pinMode(motor2ForwardPin, OUTPUT); pinMode(motor2ReversePin, OUTPUT); digitalWrite(motor1EnablePin, LOW); digitalWrite(motor1EnablePin, LOW); digitalWrite(motor1ForwardPin, LOW); digitalWrite(motor1ReversePin, LOW); digitalWrite(motor2ForwardPin, LOW); digitalWrite(motor2ReversePin, LOW); } void motor1Forward(){ digitalWrite(motor1EnablePin, HIGH); digitalWrite(motor1ForwardPin, HIGH); digitalWrite(motor1ReversePin, LOW); } void motor1Reverse(){ digitalWrite(motor1EnablePin, HIGH); digitalWrite(motor1ForwardPin, LOW); digitalWrite(motor1ReversePin, HIGH); } void motor1Stop(){ digitalWrite(motor1EnablePin, LOW); digitalWrite(motor1ForwardPin, LOW); digitalWrite(motor1ReversePin, LOW); } void motor2Forward(){ digitalWrite(motor2EnablePin, HIGH); digitalWrite(motor2ForwardPin, HIGH); digitalWrite(motor2ReversePin, LOW); } void motor2Reverse(){ digitalWrite(motor2EnablePin, HIGH); digitalWrite(motor2ForwardPin, LOW); digitalWrite(motor2ReversePin, HIGH); } void motor2Stop(){ digitalWrite(motor2EnablePin, LOW); digitalWrite(motor2ForwardPin, LOW); digitalWrite(motor2ReversePin, LOW); } void setup(){ setupMotor(); } void loop(){ motor1Forward(); delay(1000); motor1Reverse(); delay(1000); motor1Stop(); delay(1000); motor2Forward(); delay(1000); motor2Reverse(); delay(1000); motor2Stop(); delay(1000); }
Kommentaare ei ole:
Postita kommentaar