You are on page 1of 3

1

Serial.print("sensor3=\t");
Serial.println (hasilc);
Serial.print (",");
digitalWrite(ledpin, LOW);
delay(2000);
servodefault();
}
void servodefault()
{
servo2.write(85);
}

//Main program pengujian driver motor


void loop()
{
gerak(DEPAN);
delay(3000);
gerak(BELAKANG);
delay(3000);
gerak(MAJU);
delay(3000);
gerak(MUNDUR);
delay(3000);
gerak(NAIK);
delay(3000);
gerak(TURUN);
delay(3000);

void gerak(byte kondisi)


{
2

status = kondisi;
switch(kondisi)
{
case MAJU:
digitalWrite(motor2a, HIGH);
digitalWrite(motor2b, LOW);
break;
case MUNDUR:
digitalWrite(motor2a, LOW);
digitalWrite(motor2b, HIGH);
break;
case STOP:
digitalWrite(motor2a, LOW);
digitalWrite(motor2b, LOW);
break;
case NAIK:
digitalWrite(motor3a, LOW);
digitalWrite(motor3b, HIGH);
break;
case TURUN:
digitalWrite(motor3a, HIGH);
digitalWrite(motor3b, LOW);
break;
case HENTI:
digitalWrite(motor3a, LOW);
digitalWrite(motor3b, LOW);
break;
case DEPAN:
digitalWrite(motor1a, HIGH);
digitalWrite(motor1b, LOW);
break;
3

case BELAKANG:
digitalWrite(motor1a, LOW);
digitalWrite(motor1b, HIGH);
break;
case MANDEK:
digitalWrite(motor1a, LOW);
digitalWrite(motor1b, LOW);
break;
}}