I busy whit programming a arduino to control IBT_2. I want to get current sense working on it.
So when the motor pulls to mutch current it turns its direction.
Normal operation works and i can meassure the current also on it.
But in the part IF ELSE i get a error but don't understand why in example in ELSE it is not there
That is if i verify the program it says
In function 'void loop()':
60:1: error: expected ';' before '{' token
exit status 1
why does it say that. and in example it is not there. thit i do something wrong
int potpin1 = A3;
int switch1 = A1;
int switch2 = A2;
int pwm1 = 5;
int pwm2 = 6;
int enable1 = 3;
int enable2 = 2;
int output1;
int turn1;
int switcha;
int switchb;
int current;
int testcurrent;
void setup() {
digitalWrite(enable1, LOW);
digitalWrite(enable2, LOW);
delay (15);
}
void loop() {
output1 = analogRead(potpin1);
turn1 = map(output1, 0, 1023, 0, 255);
//switcha = analogRead(switch1);
//if (switcha == LOW){
// digitalWrite(enable1, LOW);
// digitalWrite(enable2, LOW);
//}
//else {
// digitalWrite(enable1, HIGH);
// digitalWrite(enable2, HIGH);
//}
//current
//resistor 1k ohm
//measured voltage/ resistor=.. * 8500 = 42.5A
//5v/1k ohm * 8500 =42.5A
testcurrent = analogRead(switch2);
current = map(testcurrent,0,1023,0,42.5);
if (current <9, pwm2 == 0)
{
analogWrite(pwm1, turn1);
analogWrite(pwm2, 0);
}
else if(current >=9, pwm2 == 0)
{
analogWrite(pwm2, turn1);
analogWrite(pwm1, 0);
}
else if (current <9, pwm1 == 0)
{
analogWrite(pwm2, turn1);
analogWrite(pwm1, 0);
}
else (current >=9, pwm1 == 0)
{
analogWrite(pwm1, turn1);
analogWrite(pwm2, 0);
}
delay (100);
}
Whit the if else it looks how mutch current is drawn and whit direction it is turning.
if this is working than i only want to make a extra potentionmeter to control maximum amperage