// sesuaikan dengan PIN yang dipasang int INA1=14; int INA2=15; int INA3=16; int INA4=17; int INB1=18; int INB2=19; int INB3=20; int INB4=21; //int step = 100; int delaytime=2; //makin kecil delay, makin cepat motor berputar int pinStatus = 13; void setup(){ pinMode(INA1,OUTPUT); pinMode(INA2,OUTPUT); pinMode(INA3,OUTPUT); pinMode(INA4,OUTPUT); pinMode(INB1,OUTPUT); pinMode(INB2,OUTPUT); pinMode(INB3,OUTPUT); pinMode(INB4,OUTPUT); pinMode(pinStatus, INPUT); Serial.begin(9600); } void loop(){ //maju 60; //for (int i=0; i<1000; i++){ if (!digitalRead(pinStatus)) { maju(); } //} Serial.println(digitalRead(pinStatus)); } void maju(){ //step 4 step1(); delay(delaytime); //step 3 step2(); delay(delaytime); //step 2 step3(); delay(delaytime); //step 1 step4(); delay(delaytime); } void mundur(){ //step 4 step4(); delay(delaytime); //step 3 step3(); delay(delaytime); //step 2 step2(); delay(delaytime); //step 1 step1(); delay(delaytime); } void step1(){ digitalWrite(INA1,LOW); digitalWrite(INB1,LOW); digitalWrite(INA2,LOW); digitalWrite(INB2,HIGH); digitalWrite(INA3,HIGH); digitalWrite(INB3,HIGH); digitalWrite(INA4,HIGH); digitalWrite(INB4,LOW); } void step2(){ digitalWrite(INA1,HIGH); digitalWrite(INB1,HIGH); digitalWrite(INA2,LOW); digitalWrite(INB2,HIGH); digitalWrite(INA3,LOW); digitalWrite(INB3,LOW); digitalWrite(INA4,HIGH); digitalWrite(INB4,LOW); } void step3(){ digitalWrite(INA1,HIGH); digitalWrite(INB1,HIGH); digitalWrite(INA2,HIGH); digitalWrite(INB2,LOW); digitalWrite(INA3,LOW); digitalWrite(INB3,LOW); digitalWrite(INA4,LOW); digitalWrite(INB4,HIGH); } void step4(){ digitalWrite(INA1,LOW); digitalWrite(INB1,LOW); digitalWrite(INA2,HIGH); digitalWrite(INB2,LOW); digitalWrite(INA3,HIGH); digitalWrite(INB3,HIGH); digitalWrite(INA4,LOW); digitalWrite(INB4,HIGH); }