Kodlar
const int IN1=5;
const int IN2 = 6;
const int IN3 = 9;
const int IN4 = 10;
const int trig=12;
const int echo=11;
long sure;
int uzaklik;
int hiz=100;
void setup(){
pinMode(IN1,OUTPUT);
pinMode(IN2,OUTPUT);
pinMode(IN3,OUTPUT);
pinMode(IN4,OUTPUT);
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
}
void loop(){
digitalWrite(trig,0);
delayMicroseconds(10);
digitalWrite(trig,1);
delayMicroseconds(10);
sure=pulseIn(echo,1);
uzaklik=(0.0343*sure)/2;
//ileri
analogWrite(IN1,hiz);
analogWrite(IN2,0);
analogWrite(IN3,hiz);
analogWrite(IN4,0);
if(uzaklik<40){
//sol
analogWrite(IN1,0);
analogWrite(IN2,hiz);
analogWrite(IN3,hiz);
analogWrite(IN4,0);
}
}
No responses yet