73-2WD çizgi izleyen

2WD araba çizgi izleyen

beyaz alan siyah çizgiyle sınırlandırılmış
üçlü çizgi sensör kartı kullanılmıştır.
sensorler beyaz görürse “1” siyah görürse “0” dijital değerini okuyor.

					

#define solsensor 4
#define ortasensor 3
#define sagsensor 2

void setup() {
  Serial.begin (9600);
}

void dur()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void ileri()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void geri()
    {
        analogWrite(5,0);
        analogWrite(6,255);
        analogWrite(9,255);
        analogWrite(10,0);
    }

void sag()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void sol()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void loop() {
    int soldeger(digitalRead(solsensor));
    int ortadeger(digitalRead(ortasensor));
    int sagdeger(digitalRead(sagsensor));
    
    Serial.print(soldeger);
    Serial.print("-");
    Serial.print(ortadeger);
    Serial.print("-");
    Serial.println(sagdeger);

  if (soldeger == 1 && sagdeger == 1 && ortadeger == 1)
    {
      dur();
    }
  else if (soldeger == 0 && sagdeger == 0 && ortadeger == 0)
    {
      dur();
    }
  else if (soldeger == 1 && sagdeger == 1 && ortadeger == 0)
    {
      ileri();
    }
  else if (soldeger == 1 && sagdeger == 0 && ortadeger == 0)
    {
      sag();
    }
  else if (soldeger == 1 && sagdeger == 0 && ortadeger == 1)
    {
      sag();
    }  
  else if (soldeger == 0 && sagdeger == 1 && ortadeger == 0)
    {
      sol();
    }
  else if (soldeger == 0 && sagdeger == 1 && ortadeger == 1)
    {
      sol();
    } 

} 

72-2WD alandan çıkmayan

2WD araba alandan çıkmayan

beyaz alan siyah çizgiyle sınırlandırılmış
üçlü çizgi sensör kartı kullanılmıştır.
sensorler beyaz görürse “1” siyah görürse “0” dijital değerini okuyor.

					

#define solsensor 4
#define ortasensor 3
#define sagsensor 2

void setup() {
  Serial.begin (9600);
}

void dur()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void ileri()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void geri()
    {
        analogWrite(5,0);
        analogWrite(6,255);
        analogWrite(9,255);
        analogWrite(10,0);
    }

void sag()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void sol()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void loop() {
    int soldeger(digitalRead(solsensor));
    int ortadeger(digitalRead(ortasensor));
    int sagdeger(digitalRead(sagsensor));
    
    Serial.print(soldeger);
    Serial.print("-");
    Serial.print(ortadeger);
    Serial.print("-");
    Serial.println(sagdeger);

  if (soldeger == 0 || ortadeger == 0 || sagdeger == 0)
    {
        geri();
    delay(1000);
    sol();
    delay(1000);
    }
  else
  {
    ileri();
  }
} 

71-2WD araba ışık izleyen

2WD araba ışık izleyen
					

int sagldr = A2;
int ortaldr = A1;
int solldr = A0;

int sagldrdeger =0;
int ortaldrdeger =0;
int solldrdeger =0;

void setup() {
      Serial.begin(9600);
}
void dur()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void ileri()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void geri()
    {
        analogWrite(5,0);
        analogWrite(6,255);
        analogWrite(9,255);
        analogWrite(10,0);
    }

void sag()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void sol()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void loop() {
  sagldrdeger = analogRead(sagldr);
  ortaldrdeger = analogRead(ortaldr);
  solldrdeger = analogRead(solldr);

  Serial.print(solldrdeger);
  Serial.print("-");
  Serial.print(ortaldrdeger);
  Serial.print("-");
  Serial.print(sagldrdeger);
  Serial.println("-");

  if(ortaldrdeger > sagldrdeger && ortaldrdeger > solldrdeger)
    {
        ileri();
    }
  else if(solldrdeger > sagldrdeger && solldrdeger > ortaldrdeger)
    {
        sol();
    }
  else if(sagldrdeger > solldrdeger && sagldrdeger > ortaldrdeger)
    {
        sag();
    }
  else
    {
        dur();
    }

}

 

70-2WD araba engelden kaçan

2WD araba engelden kaçan
					

#define trigPin 13
#define echoPin 12

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Serial.begin (9600);
       
}

void dur()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void ileri()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void geri()
    {
        analogWrite(5,0);
        analogWrite(6,255);
        analogWrite(9,255);
        analogWrite(10,0);
    }

void sag()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void sol()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void loop() {
  int sure, mesafe;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  sure = pulseIn(echoPin, HIGH);
  mesafe = sure/58; 
  
    Serial.print(mesafe);
    Serial.println(" cm");

  if (!(mesafe < 10))
    {
        ileri();
    }
  else
  {
    geri();
    delay(1000);
    sol();
    delay(1000);
  }
} 

69-2WD araba IR (infrared)(kızılötesi) kumanda kontrol

2WD araba IR (infrared)(kızılötesi) kumanda kontrol

IR kumanda kütüohanesi için tıklayınız.

					

#include <IRremote.h>

int RECV_PIN = 8;
IRrecv irrecv(RECV_PIN);
decode_results results;

#define CH1 0xFFA25D
#define CH 0xFF629D
#define CH2 0xFFE21D
#define PREV 0xFF22DD
#define NEXT 0xFF02FD
#define PLAYPAUSE 0xFFC23D
#define VOL1 0xFFE01F
#define VOL2 0xFFA857
#define EQ 0xFF906F
#define BUTON0 0xFF6897
#define BUTON100 0xFF9867
#define BUTON200 0xFFB04F
#define BUTON1 0xFF30CF
#define BUTON2 0xFF18E7
#define BUTON3 0xFF7A85
#define BUTON4 0xFF10EF
#define BUTON5 0xFF38C7
#define BUTON6 0xFF5AA5
#define BUTON7 0xFF42BD
#define BUTON8 0xFF4AB5
#define BUTON9 0xFF52AD

void setup() {
irrecv.enableIRIn();   
}

void dur()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }
void ileri()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }
void geri()
    {
        analogWrite(5,0);
        analogWrite(6,255);
        analogWrite(9,255);
        analogWrite(10,0);
    }
void sag()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }
void sol()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }
void loop() {

  if (irrecv.decode(&results))
    {
    if (results.value == BUTON2)
    {
      ileri();
    }
    if (results.value == BUTON8)
    {
      geri();
    }
    if (results.value == BUTON6)
    {
      sag();
    }
    if (results.value == BUTON4)
    {
      sol();
    }
    if (results.value == BUTON5)
    {
      dur();
    }
    
    irrecv.resume();  
  }
}  

 

68-2WD araba joystick kontrol

2WD Araba joystick kontrol.

					

void setup() {
      
}
void dur()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void ileri()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void geri()
    {
        analogWrite(5,0);
        analogWrite(6,255);
        analogWrite(9,255);
        analogWrite(10,0);
    }

void sag()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void sol()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void loop() {
  if(analogRead(A1) < 400)
    {
        ileri();
    }
  else if(analogRead(A1) > 600)
    {
        geri();
    }
  else if(analogRead(A0) < 400)
    {
        sol();
    }
  else if(analogRead(A0) > 600)
    {
        sag();
    }
  else
    {
        dur();
    }

}

 

67-2WD Araba temel hareketler

2WD Araba Motorlar ve bağlantılar test için temel hareketler.

					

void setup() {
    ileri();
    delay(1000);
    dur();
    delay(1000);
    geri();
    delay(1000);
    dur();
    delay(1000);
    sag();
    delay(1000);
    dur();
    delay(1000);
    sol();
    delay(1000);
    dur();
    delay(1000);
      
}


void dur()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void ileri()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void geri()
    {
        analogWrite(5,0);
        analogWrite(6,255);
        analogWrite(9,255);
        analogWrite(10,0);
    }

void sag()
    {
        analogWrite(5,0);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,255);
    }

void sol()
    {
        analogWrite(5,255);
        analogWrite(6,0);
        analogWrite(9,0);
        analogWrite(10,0);
    }

void loop() {
    
}

 

 

66-IR (infrared)(kızılötesi) kumanda uygulaması

IR kumanda değer okuma arduino üzerindeki 13 nolu ledi yakma.

IR kumanda kütüphanesi için tıklayınız.

					

#include <IRremote.h>

#define CH1 0xFFA25D
#define CH 0xFF629D
#define CH2 0xFFE21D
#define PREV 0xFF22DD
#define NEXT 0xFF02FD
#define PLAYPAUSE 0xFFC23D
#define VOL1 0xFFE01F
#define VOL2 0xFFA857
#define EQ 0xFF906F
#define BUTON0 0xFF6897
#define BUTON100 0xFF9867
#define BUTON200 0xFFB04F
#define BUTON1 0xFF30CF
#define BUTON2 0xFF18E7
#define BUTON3 0xFF7A85
#define BUTON4 0xFF10EF
#define BUTON5 0xFF38C7
#define BUTON6 0xFF5AA5
#define BUTON7 0xFF42BD
#define BUTON8 0xFF4AB5
#define BUTON9 0xFF52AD

int RECV_PIN = 2;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver

  pinMode(13, OUTPUT);
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);

    
    if (results.value == BUTON2)
        digitalWrite(13,HIGH);
    else
        digitalWrite(13,LOW);
   
    irrecv.resume(); // Receive the next value
  }
  delay(100);

  
}

IR kumanda aynı tuşla yakıp söndürme.
					

#include <IRremote.h>

int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;

#define CH1 0xFFA25D
#define CH 0xFF629D
#define CH2 0xFFE21D
#define PREV 0xFF22DD
#define NEXT 0xFF02FD
#define PLAYPAUSE 0xFFC23D
#define VOL1 0xFFE01F
#define VOL2 0xFFA857
#define EQ 0xFF906F
#define BUTON0 0xFF6897
#define BUTON100 0xFF9867
#define BUTON200 0xFFB04F
#define BUTON1 0xFF30CF
#define BUTON2 0xFF18E7
#define BUTON3 0xFF7A85
#define BUTON4 0xFF10EF
#define BUTON5 0xFF38C7
#define BUTON6 0xFF5AA5
#define BUTON7 0xFF42BD
#define BUTON8 0xFF4AB5
#define BUTON9 0xFF52AD

int led1 = 8;


void setup()
{
  pinMode(led1, OUTPUT);
  
  Serial.begin(9600);
  irrecv.enableIRIn();
}
void loop() {

  if (irrecv.decode(&results))
  {
    if (results.value == BUTON1)
    {
      digitalWrite(led1, !digitalRead(led1));
      if (digitalRead(led1) == HIGH)
      {
        Serial.println("LED 1 yandi");
      }
      else
      {
        Serial.println("LED 1 sondu");
      }
    }
    
    irrecv.resume();
  }
}

IR kumanda ledler uygulaması.
					

#include <IRremote.h>

int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;

#define CH1 0xFFA25D
#define CH 0xFF629D
#define CH2 0xFFE21D
#define PREV 0xFF22DD
#define NEXT 0xFF02FD
#define PLAYPAUSE 0xFFC23D
#define VOL1 0xFFE01F
#define VOL2 0xFFA857
#define EQ 0xFF906F
#define BUTON0 0xFF6897
#define BUTON100 0xFF9867
#define BUTON200 0xFFB04F
#define BUTON1 0xFF30CF
#define BUTON2 0xFF18E7
#define BUTON3 0xFF7A85
#define BUTON4 0xFF10EF
#define BUTON5 0xFF38C7
#define BUTON6 0xFF5AA5
#define BUTON7 0xFF42BD
#define BUTON8 0xFF4AB5
#define BUTON9 0xFF52AD

int led1 = 8;
int led2 = 9;
int led3 = 10;
int led4 = 11;

void setup()
{
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  Serial.begin(9600);
  irrecv.enableIRIn();
}
void loop() {

  if (irrecv.decode(&results))
  {
    if (results.value == BUTON1)
    {
      digitalWrite(led1, !digitalRead(led1));
      if (digitalRead(led1) == HIGH)
      {
        Serial.println("LED 1 yandi");
      }
      else
      {
        Serial.println("LED 1 sondu");
      }
    }
    if (results.value == BUTON2)
    {
      digitalWrite(led2, !digitalRead(led2));
      if (digitalRead(led2) == HIGH)
      {
        Serial.println("LED 2 yandi");
      }
      else
      {
        Serial.println("LED 2 sondu");
      }
    }
    if (results.value == BUTON3)
    {
      digitalWrite(led3, !digitalRead(led3));
      if (digitalRead(led3) == HIGH)
      {
        Serial.println("LED 3 yandi");
      }
      else
      {
        Serial.println("LED 3 sondu");
      }
    }
    if (results.value == BUTON4)
    {
      digitalWrite(led4, !digitalRead(led4));
      if (digitalRead(led4) == HIGH)
      {
        Serial.println("LED 4 yandi");
      }
      else
      {
        Serial.println("LED 4 sondu");
      }
    }
    if (results.value == BUTON0)
    {
      digitalWrite(led1, LOW);
      digitalWrite(led2, LOW);
      digitalWrite(led3, LOW);
      digitalWrite(led4, LOW);
      Serial.println("Tum LED'ler sondu");
    }
    if (results.value == BUTON5)
    {
      digitalWrite(led1, HIGH);
      digitalWrite(led2, HIGH);
      digitalWrite(led3, HIGH);
      digitalWrite(led4, HIGH);
      Serial.println("Tum LED'ler yandi");
    }
    irrecv.resume();
  }
}

65- HC-SR04 Mesafe sensörü uygulaması

HC-SR04 Mesafe sensörü değer okuma
					

#define trigPin 13
#define echoPin 12
 
void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}
 
void loop() {
  int sure, mesafe;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  sure = pulseIn(echoPin, HIGH);
  mesafe = sure/58; 
  
    Serial.print(mesafe);
    Serial.println(" cm");
  }

HC-SR04 mesafe sensörü değerini LCD ekranda görüntüleme
i2c ‘li LCD kütüphanesi için tıklayınız.
					

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#define trigPin 13
#define echoPin 12
 
LiquidCrystal_I2C lcd(0x27, 16, 2);
 
void setup()
{
  lcd.begin();   // LCD'nin 16 karakter 2 satır olduğunu belirtiyoruz.
  lcd.backlight();   // LCD arkaplan ışığını (led) yak
  //lcd.noBacklight(); // LCD arkaplan ışığını (led) söndür

  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
} 
void loop(){
  int sure, mesafe;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  sure = pulseIn(echoPin, HIGH);
  mesafe = sure/58;

// Ekrana yazdırılacak metin
lcd.setCursor(0,0);
lcd.print("turker robotik");
lcd.setCursor(0,1);
lcd.print("mesafe: ");
lcd.setCursor(8,1);
lcd.print(mesafe);
delay(1000);
lcd.clear();
}

HC-SR04 mesafe sensörü ile park sensörü yapımı
					

#define trigPin 13
#define echoPin 12
int led1=4;
int led2=5;
int led3=6;
int led4=7;
int buzzer=2;
 
void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(buzzer, OUTPUT);
}
 
void loop() {
  int sure, mesafe;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  sure = pulseIn(echoPin, HIGH);
  mesafe = sure/58; 
  
    Serial.print(mesafe);
    Serial.println(" cm");

    if (mesafe>30 && mesafe<40){
          digitalWrite(led1, HIGH);
          digitalWrite(led2, LOW);
          digitalWrite(led3, LOW);
          digitalWrite(led4, LOW);
          tone(buzzer, 250);
          
          
        }
    if (mesafe>20 && mesafe<30){
          digitalWrite(led1, HIGH);
          digitalWrite(led2, HIGH);
          digitalWrite(led3, LOW);
          digitalWrite(led4, LOW);
          tone(buzzer, 500);
        }
    if (mesafe>10 && mesafe<20){
          digitalWrite(led1, HIGH);
          digitalWrite(led2, HIGH);
          digitalWrite(led3, HIGH);
          digitalWrite(led4, LOW);
          tone(buzzer, 750);
        }
    if (mesafe>0 && mesafe<10){
          digitalWrite(led1, HIGH);
          digitalWrite(led2, HIGH);
          digitalWrite(led3, HIGH);
          digitalWrite(led4, HIGH);
          tone(buzzer, 1000);
        }
    if (mesafe>40){
          digitalWrite(led1, LOW);
          digitalWrite(led2, LOW);
          digitalWrite(led3, LOW);
          digitalWrite(led4, LOW);
          noTone(buzzer);
        }
    
}

 

64-DHT11 Sıcaklık ve nem sensörü uygulaması

DHT11 Sıcaklık ve nem sensörü değer okuma

DHT11 kütüphanesi için tıklayınız.

					

#include <dht11.h>
#define DHT11PIN 2

dht11 DHT11;
 
void setup()
{
  Serial.begin(9600);   
} 
void loop(){
  int chk = DHT11.read(DHT11PIN);

// Ekrana yazdırılacak metin
Serial.print("SICAKLIK: ");
Serial.print((float)DHT11.temperature, 2);
Serial.print(" - ");
Serial.print("NEM: ");
Serial.println((float)DHT11.humidity, 2);
delay(500);
}

DHT11 Sıcaklık ve nem sensörü LCD display de görüntüleme

DHT11 sıcaklık ve nem sensörü kütüphanesi için tıklayınız.
i2c modüllü LCD kütüphanesi için tıklayınız.

					

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <dht11.h>
#define DHT11PIN 2

dht11 DHT11;
 
LiquidCrystal_I2C lcd(0x27, 16, 2);
 
void setup()
{
  lcd.begin();   // LCD'nin 16 karakter 2 satır olduğunu belirtiyoruz.
  lcd.backlight();   // LCD arkaplan ışığını (led) yak
  //lcd.noBacklight(); // LCD arkaplan ışığını (led) söndür

} 
void loop(){
  int chk = DHT11.read(DHT11PIN);

// Ekrana yazdırılacak metin
lcd.setCursor(0,0);
lcd.print("SICAKLIK: ");
lcd.setCursor(10,0);
lcd.print((float)DHT11.temperature, 2);
lcd.setCursor(0,1);
lcd.print("NEM: ");
lcd.setCursor(10,1);
lcd.print((float)DHT11.humidity, 2);
delay(1000);
}