Problemi con Arduino Motor Shield e Arduino UNO

Buongiorno a tutti!
Per la terza volta che chiedo aiuto sul forum(in circa tre mesi...), vi do una bella gatta da...rasare a zero! :slight_smile: :slight_smile:
Allora, ho da poco comprato una motor Shield per Arduino UNO per comandare 2 motori in continua...(scheda tecnica: OPITEC - Fabbisogno per attività creative, manualità, pittura e decorazioni).
Ho cercato di alimentare i motori con una batteria da 9 volt, mentre le schede le alimentavo a USB, ma, seppur stringendo la morsettiera, non si accendevano i LED che indicano l'elettricità che arriva ai motori(presente sulla scheda Shield). La scheda Arduino accendeva i led ON, TX RX(quando necessario...), ma quelli della scheda Shield (sempre quelli dei famosi motori!!) si accendevano a volte quando spostavo un po' i cavi(li ho provati tutti: fili intrecciati, rame sottile e da breadboard[da scheda milliforata]). Come codice ho usato questo:

/* 
* Sketch Test Motori Shield FE 
* 
* @author: Alfieri Mauro 
* @see: by Giant Savings Extension" href="#" in_rurl="http://i.trkjmp.com/click?v=SVQ6MTg0ODM6OTc3Omh0dHA6OTdjNDFmNDc2YzhmYmEwYmNmMmFmNzgzYzEyMWE5MzQ6ei0xMjQyLTEyNDkwMTp3d3cubWF1cm9hbGZpZXJpLml0OjIwOTAwOjM3YzFmYzUwMjIzYzlmMWE3N2YwYTE4MDlmZDFhMDk3"http://www.mauroalfieri.it 
* 
* @licenze: Creative common 
*/
int pinDirA=2; 
int pinDirB=8; 
int pinPwmA=3; 
int pinPwmB=9; 
void setup() 
{ 
pinMode( pinDirA,OUTPUT ); 
pinMode( pinPwmA,OUTPUT ); 
pinMode( pinDirB,OUTPUT ); 
pinMode( pinPwmB,OUTPUT ); 
} 
void loop() 
{ 
// Test: rotazione dei motori 
// stessa direzione, vel 
digitalWrite( pinDirA,HIGH ); 
digitalWrite( pinDirB,HIGH ); 
// velocità massima 
analogWrite( pinPwmA,255 ); 
analogWrite( pinPwmB,255 ); 
delay(5000); 
// Test: rotazione dei motori 
// direzione inversa 
digitalWrite( pinDirA,LOW ); 
digitalWrite( pinDirB,LOW ); 
// velocità massima 
analogWrite( pinPwmA,255 ); 
analogWrite( pinPwmB,255 ); 
delay(5000); 
// Test: rotazione dei motori 
// direzione incrociata 
digitalWrite( pinDirA,HIGH ); 
digitalWrite( pinDirB,LOW ); 
// velocità massima 
analogWrite( pinPwmA,255 ); 
analogWrite( pinPwmB,255 ); 
delay(5000); 
// Test: rotazione dei motori 
// direzione incrociata 
digitalWrite( pinDirA,LOW ); 
digitalWrite( pinDirB,HIGH ); 
// velocità massima 
analogWrite( pinPwmA,255 ); 
analogWrite( pinPwmB,255 ); 
delay(5000); 
// Test: stop dei motori 
// nessuna direzione 
digitalWrite( pinDirA,HIGH ); 
digitalWrite( pinDirB,HIGH ); 
// velocità nulla 
analogWrite( pinPwmA,0 ); 
analogWrite( pinPwmB,0 ); 
delay(5000); 
}

che proviene da qui: Tutorial: collega la Motor Shield e pilota i motori - Mauro Alfieri Wearable Domotica Robotica Elettronica, Robotica e Domotica
Ma non parte nulla!!!
grazie a tutti quelli che vorranno aiutarmi!

Domanda banale: hai messo bene i jumper?

Poi non capisco perchè tutti quei:
analogWrite( pinPwmA,255 );
analogWrite( pinPwmB,255 );

La batteria é piena? È meglio se usi una batteria da 4,5V visto che i motori non sono per 9V.

Secondo me l' errore é nel cablaggio dei motori.
Puoi fare un circuito e spedirci una doto dove si vede come hai collegato la batteria e i motori?
Ciao Grazie Uwe

Lo sketch funziona(ho sostituito i motori con dei led e funzonavano alla grande).

Domanda banale: hai messo bene i jumper?

Quanto al Jumper : Cos'è e dove si trova???
La scheda motor shield che ho utilizzato è a versione Rev3.

Secondo me l' errore é nel cablaggio dei motori.

Credo che il problema sia nei collegamneti con la morsettiera.

La batteria é piena?

Sì, la batteria é piena e ben funzionante(nuova di zecca!)

Puoi fare un circuito e spedirci una doto dove si vede come hai collegato la batteria e i motori?

cerchero di spedirvi la foto al più presto!

Poi non capisco perchè tutti quei:
analogWrite( pinPwmA,255 );
analogWrite( pinPwmB,255 );

serve a regolare la velocità!

Sono contenot che abbiate risposto, GRAZIE!!!

Ottimo.

Pensavo avessi lo stesso shield dell'articolo da cui hai preso il sorgente dove devi usare i jumper per impostare i pin usati..

Credo che abbia sbagliato i pin.
Se hai la shield ufficiale:

Input and Output
This shield has two separate channels, called A and B, that each use 4 of the Arduino pins to drive or sense the motor. In total there are 8 pins in use on this shield. You can use each channel separately to drive two DC motors or combine them to drive one unipolar stepper motor.
The shield's pins, divided by channel are shown in the table below:

Function pins per Ch. A pins per Ch. B
Direction D12 D13
PWM D3 D11
Brake D9 D8
Current Sensing A0 A1

If you don't need the Brake and the Current Sensing and you also need more pins for your application you can disable this features by cutting the respective jumpers on the back side of the shield.
The additional sockets on the shield are described as follow:
Screw terminal to connect the motors and their power supply.
2 TinkerKit connectors for two Analog Inputs (in white), connected to A2 and A3.
2 TinkerKit connectors for two Aanlog Outputs (in orange in the middle), connected to PWM outputs on pins D5 and D6.
2 TinkerKit connectors for the TWI interface (in white with 4 pins), one for input and the other one for output.

Motors connections
Brushed DC motor. You can drive two Brushed DC motors by connecting the two wires of each one in the (+) and (-) screw terminals for each channel A and B. In this way you can control its direction by setting HIGH or LOW the DIR A and DIR B pins, you can control the speed by varying the PWM A and PWM B duty cycle values. The Brake A and Brake B pins, if set HIGH, will effectively brake the DC motors rather than let them slow down by cutting the power. You can measure the current going through the DC motor by reading the SNS0 and SNS1 pins. On each channel will be a voltage proportional to the measured current, which can be read as a normal analog input, through the function analogRead() on the analog input A0 and A1. For your convenience it is calibrated to be 3.3V when the channel is delivering its maximum possible current, that is 2A.

Segui questo tutorial --> http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/?ALLSTEPS

Schema collegamento

Sketch

/*************************************************************
Motor Shield 2-Channel DC Motor Demo
by Randy Sarafan

For more information see:
http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/

*************************************************************/

void setup() {
  
  //Setup Channel A
  pinMode(12, OUTPUT); //Initiates Motor Channel A pin
  pinMode(9, OUTPUT); //Initiates Brake Channel A pin

  //Setup Channel B
  pinMode(13, OUTPUT); //Initiates Motor Channel A pin
  pinMode(8, OUTPUT);  //Initiates Brake Channel A pin
 
}

void loop(){

  //Motor A forward @ full speed
  digitalWrite(12, HIGH); //Establishes forward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 255);   //Spins the motor on Channel A at full speed

  //Motor B backward @ half speed
  digitalWrite(13, LOW);  //Establishes backward direction of Channel B
  digitalWrite(8, LOW);   //Disengage the Brake for Channel B
  analogWrite(11, 123);    //Spins the motor on Channel B at half speed

  delay(3000);

  digitalWrite(9, HIGH);  //Engage the Brake for Channel A
  digitalWrite(9, HIGH);  //Engage the Brake for Channel B

  delay(1000);
  
  
  //Motor A forward @ full speed
  digitalWrite(12, LOW);  //Establishes backward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 123);    //Spins the motor on Channel A at half speed
  
  //Motor B forward @ full speed
  digitalWrite(13, HIGH); //Establishes forward direction of Channel B
  digitalWrite(8, LOW);   //Disengage the Brake for Channel B
  analogWrite(11, 255);   //Spins the motor on Channel B at full speed

  delay(3000);

  digitalWrite(9, HIGH);  //Engage the Brake for Channel A
  digitalWrite(9, HIGH);  //Engage the Brake for Channel B

  delay(1000);

}

che cavolo vuol dire saltare/tagliare il Vin Connect??E'il traduttore di google che spara fischi per fiaschi o cosa???

alberto01:
che cavolo vuol dire saltare/tagliare il Vin Connect??E'il traduttore di google che spara fischi per fiaschi o cosa???

Riporta la frase in inglese, almeno si capisce il verbo che hanno usato.

This is possible by cutting the "Vin Connect" jumper placed on the back side of the shield.

alberto01:
This is possible by cutting the "Vin Connect" jumper placed on the back side of the shield.

To cut significa proprio "tagliare" nel senso letterale del termine, tagliare. Sicuramente c'è un jumper fatto con una piazzola ed una piccola traccia di stagno (ad esempio quello del RESET-EN dell'Arduino), che va interotto come riporta il testo:

Ciò è possibile tagliando [interrompendo] il ponticello "Vin Connect" posto nella parte posteriore dello shield.

Il ponticello di cui si parla é quella pista sottile tra le due piazzette stagnate in basso al centro dove é scritto vicino "Vin connect".

Ciao Uwe