Reputation: 11
I am controlling motor with raspberry pi, using wiringPi. I made my code, and implemented. It worked. But when I exit the code, motor was still working. How can I stop this?
while(1){
digitalWrite(EN1, HIGH);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
delay(10000);
digitalWrite(EN1, LOW);
delay(5000);
digitalWrite(EN1, HIGH);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
delay(10000);
digitalWrite(EN1, LOW);
delay(5000);
}
Upvotes: 1
Views: 92
Reputation: 3205
Because of your
while (1)
I understand you stop with a signal, like Ctrl-C. You should use signal handler to handle the stop and when you catch the signal, you should stop the motors with
digitalWrite(EN1, LOW);
Upvotes: 1