I am new in using arduino and especially arduino motor shield and I cannot deal with this shield I tried this program but it doesnot work I know it have mistakes but I am searching in the web but I cannot find a solution
the program that I need to read two switches every switch will forward or reverse some motors
I used if statement and I do not know what is the wrong with the program
this a simple program of what I want
int sensor1 = 2;
int dirA = 12;
int speedA = 3;
int val1 = 0;
void setup() {
pinMode(sensor1, INPUT);
pinMode(dirA, OUTPUT);
pinMode(speedA, OUTPUT);
}
void loop() {
val1 = digitalRead(sensor1);
if (val1 == HIGH)
{
digitalWrite(dirA, HIGH);
analogWrite(speedA, 128);
}
else
{
digitalWrite(dirA, LOW);
analogWrite(speedA, 0);
}
}