int motorA1 = 10; // L298N'in IN2 Girişi
int motorA2 = 11; // L298N'in IN1 Girişi
int motorB1 = 8; // L298N'in IN4 Girişi
int motorB2 = 9; // L298N'in IN3 Girişi
int veri;
void setup() {
pinMode(motorA1, OUTPUT);
pinMode(motorA2, OUTPUT);
pinMode(motorB1, OUTPUT);
pinMode(motorB2, OUTPUT);
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0){
veri = Serial.read();
}
/***********************İleri*****************************/
if (veri == 'F') {
digitalWrite(motorA1, 1); digitalWrite(motorA2, 0);
digitalWrite(motorB1, 1); digitalWrite(motorB2, 0);
}
/***********************Geri******************************/
else if (veri == 'B') {
digitalWrite(motorA1, 0); digitalWrite(motorA2, 1);
digitalWrite(motorB1, 0); digitalWrite(motorB2, 1);
}
/***************************Sol***************************/
else if (veri == 'L') {
digitalWrite(motorA1, 1); digitalWrite(motorA2, 0);
digitalWrite(motorB1, 0); digitalWrite(motorB2, 1);
}
/***************************Sağ***************************/
else if (veri == 'R') {
digitalWrite(motorA1, 0); digitalWrite(motorA2, 1);
digitalWrite(motorB1, 1); digitalWrite(motorB2, 0);
}
/************************Stop*****************************/
else if (veri == 'S'){
digitalWrite(motorA1, 0); digitalWrite(motorA2, 0);
digitalWrite(motorB1, 0); digitalWrite(motorB2, 0);
}
}