Código do blink adaptado para rodar um motor DC.
Dá para controlar a velocidade usando a saída PWM.
/*
Motor1
Turns on a motor on for one second, then off for one second, repeatedly.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int motor1 = 2;
int motor2 = 3; // PWM output
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(motor1, OUTPUT);
pinMode(motor2, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(motor1, HIGH);
digitalWrite(motor2, LOW);
delay(1000);
digitalWrite(motor1, LOW);
delay(1000);
}
Nenhum comentário:
Postar um comentário