Hi,
I'm having some REALLY weird bugs with my motor shield.
I tested every connection and everything looks fine.
However, when I put the speed 0 in my programme, the voltage is at its maximum and when I put the speed at 255 (manualy), there is no longer any voltage.
Also, only ONE of my motors can to go in reverse! The other one can't get any voltage in reverse.
I just want to be sure if it's not a programming issue. I'm new to programming.
Thank you,
Max.
These are my variables:
// Nom pour les pin directionnel du motorshield
const unsigned char M1DIR = 7;
const unsigned char M2DIR = 8;
const unsigned char M1PWM = 9;
const unsigned char M2PWM = 10;
const unsigned char LED = 13;
// Déclaration des variables
int vitesse;
int delai;
int DIR1;
int DIR2;
This is my setup
void setup() {
// put your setup code here, to run once:
//On setup toute les pins directionnelles et le LED
Serial.begin(9600);
pinMode(M1PWM, OUTPUT);
pinMode(M2PWM, OUTPUT);
pinMode(M1DIR, OUTPUT);
pinMode(M2DIR, OUTPUT);
pinMode(LED, OUTPUT);
}
This is my loop when I try to use directly my motor without using my functions to avoid errors.
void loop() {
digitalWrite(M1DIR,LOW);
digitalWrite(M2DIR,LOW);
digitalWrite(LED,LOW);
analogWrite(M1PWM,0);
analogWrite(M2PWM,0);
delay(5000);
digitalWrite(LED,HIGH);
analogWrite(M1PWM,255);
analogWrite(M2PWM,255);
delay(5000);
digitalWrite(M1DIR,HIGH);
digitalWrite(M2DIR,HIGH);
digitalWrite(LED,LOW);
analogWrite(M1PWM,0);
analogWrite(M2PWM,0);
delay(5000);
digitalWrite(LED,HIGH);
analogWrite(M1PWM,255);
analogWrite(M2PWM,255);
delay(5000);
}