i have written the code below there are no errors shown but when connected to the motor there is no movement .Can you please tell me if the code will execute.
int pin1=7;
int pin2=6;
int enb=5;
int pot=A0;
int TurnDirection;
enum TurnDirection {right, left};
int M_Speed;
int traget;
int GoToAngle;
void setup() {
pinMode(pin1,OUTPUT);
pinMode (pin2,OUTPUT);
pinMode(enb,OUTPUT);
pinMode(pot,INPUT);
Serial.begin(9600);
}
void loop()
{
int val =600;
analogWrite(pot,val);
}
void SetTurnDirection(int dir)
{
TurnDirection=dir;
switch(TurnDirection)
{
case right:
digitalWrite(pin1,HIGH);
digitalWrite (pin2,LOW);
break;
case left:
digitalWrite(pin1,LOW);
digitalWrite (pin2,HIGH);
break;
}
}
void SetTurnSpeed(int s)
{
M_Speed=s;
}
void Turn()
{
analogWrite (enb,200);
}
void Stop()
{
analogWrite(enb,0);
}
void SetGoToAngle( )
{
int val;
int currentAngle = analogRead(A0);
if (currentAngle<val)
{
SetTurnDirection(right);
}
if(currentAngle>val)
{
SetTurnDirection(left);
}
Turn();
delay(100);
Stop();
}