salve a tutti, stasera volevo provare a comandare un motore dc tramite un ponte h. Ho seguito questo piccolo corso, ho controllato e tutti i collegamenti sono giusti, ho letto anche il datasheet del ponte h e tutto sembra corrispondere, ma il motore non parte .
Ciao, mi piacerebbe capire il funzionamento anche a mè, appena ho un attimo voglio leggermi i tuoi link e provare anche io,
spero che il "ponte H" e il motore giusti siano già nel mio kit
const int switchPin = 2; // switch input
const int motor1Pin = 3; // H-bridge leg 1 (pin 2, 1A)
const int motor2Pin = 4; // H-bridge leg 2 (pin 7, 2A)
const int enablePin = 9; // H-bridge enable pin
const int ledPin = 13; // LED
void setup() {
// set the switch as an input:
pinMode(switchPin, INPUT);
// set all the other pins you're using as outputs:
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(ledPin, OUTPUT);
// set enablePin high so that motor can turn on:
digitalWrite(enablePin, HIGH);
// blink the LED 3 times. This should happen only once.
// if you see the LED blink three times, it means that the module
// reset itself,. probably because the motor caused a brownout
// or a short.
blink(ledPin, 3, 100);
}
void loop() {
// if the switch is high, motor will turn on one direction:
if (digitalRead(switchPin) == HIGH) {
digitalWrite(motor1Pin, LOW); // set leg 1 of the H-bridge low
digitalWrite(motor2Pin, HIGH); // set leg 2 of the H-bridge high
}
// if the switch is low, motor will turn in the other direction:
else {
digitalWrite(motor1Pin, HIGH); // set leg 1 of the H-bridge high
digitalWrite(motor2Pin, LOW); // set leg 2 of the H-bridge low
}
}
/*
blinks an LED
*/
void blink(int whatPin, int howManyTimes, int milliSecs) {
int i = 0;
for ( i = 0; i < howManyTimes; i++) {
digitalWrite(whatPin, HIGH);
delay(milliSecs/2);
digitalWrite(whatPin, LOW);
delay(milliSecs/2);
}
}
per caso ti blinka il LED 13 più di 3 volte ad accensione di arduino? se si, forse il motore assorbe troppo e causa un "brown out", te lo dice la nota all'interno dello sketch del tutorial (ovvero, assorbendo troppo causa una caduta di tensione troppo elevata e l'arduino si resetta. Per il resto, in attesa di foto. ciao