Toplam 3 adet sonuctan sayfa basi 1 ile 3 arasi kadar sonuc gösteriliyor
  1. #1

    Standart 42. Mause ile 2 eksen kontrol

    Bu dersimizde bir platformu mause ile 2 eksen (sağ - sol ve yukarı - aşağı) hareket ettirmeyi öğreneceğiz. Platforma ben örnek olarak bir kaç tane led bağladım. Led yerine kamera ya da projektör gibi başka metaryeller bağlayarak bu metaryalleri 2 eksen kontrol edebilirsiniz. PC arayüzü olarak processingi kullanacağız. İhtiyaç duyulması halinde konuya ait dosyaları orjinal konu ekinden (üyelik gerektirir)indirebilirsiniz.
    scriptaccess" value="always">



    Malzeme listesi:
    Arduino uno
    2 adet servo motor
    Pan tilt servo motor montaj kiti
    DC güç kaynağı (Pil ya daadaptör 6 Volt)
    Bağlantı kaboları
    Deney bordu

    Fritzing çizimi:


    Arduino kodlarımız:
    description">Kod:
    #include <Servo.h>
    
    Servo yservo;  Servo xservo; // servos for x and y
    //set initial values for x and y
    int ypos = 0;
    int xpos= 0;
    
    void setup(){
      xservo.attach(14); //(analog pin 0) for the x servo
      yservo.attach(15);  //(analog pin 1) for the y server
     
      Serial.begin(19200); // 19200 is the rate of communication
      Serial.println("Rolling"); // some output for debug purposes.
     
    }
    
    void loop() {
      static int v = 0; // value to be sent to the servo (0-180)
      if ( Serial.available()) {
        char ch = Serial.read(); // read in a character from the serial port and assign to ch
        switch(ch) { // switch based on the value of ch
          case '0'...'9': // if it's numeric
            v = v * 10 + ch - '0';
            /*
               so if the chars sent are 45x (turn x servo to 45 degs)..
               v is the value we want to send to the servo and it is currently 0
               The first char (ch) is 4 so
               0*10 = 0 + 4 - 0 = 4;
               Second char is 4;
               4*10 = 40 + 5 = 45 - 0 = 45;
               Third char is not a number(0-9) so we  drop through...
            */
            break;
          case 'x': // if it's x
          /*
           ....and land here
           where we send the value of v which is now 45 to the x servo
           and then reset v to 0
          */
            xservo.write(v);
            v = 0;
            break;
          case 'y':
            yservo.write(v);
            v = 0;
            break;
        }
      }
    }
    Processing kodlarımız:
    Kod:
    import processing.serial.*;       
    
    int xpos=90; // set x servo's value to mid point (0-180);
    int ypos=90; // and the same here
    Serial port; // The serial port we will be using
    
    void setup()
    {
      size(360, 360);
      frameRate(100);
      println(Serial.list()); // List COM-ports
      //select second com-port from the list (COM3 for my device)
      // You will want to change the [1] to select the correct device
      // Remember the list starts at [0] for the first option.
      port = new Serial(this, Serial.list()[0], 19200);
    }
    
    void draw()
    {
      fill(175);
      rect(0,0,360,360);
      fill(255,0,0); //rgb value so RED
      rect(180, 175, mouseX-180, 10); //xpos, ypos, width, height
      fill(0,255,0); // and GREEN
      rect(175, 180, 10, mouseY-180);
      update(mouseX, mouseY);
    }
    
    void update(int x, int y)
    {
      //Calculate servo postion from mouseX
      xpos= x/2;
      ypos = y/2;
      //Output the servo position ( from 0 to 180)
      port.write(xpos+"x");
      port.write(ypos+"y");
    }

  2. #2

    Standart

    O el senin mi hocam? Öpülür o el.

    Eline, emeğine sağlık.

  3. #3

    Standart

    O el benim Sinan Bey. Teşekkür ederim.

Konu Bilgileri

Bu Konuya Gözatan Kullanıcılar

Şu anda 1 kullanıcı bu konuyu görüntülüyor. (0 kayıtlı ve 1 misafir)

Benzer Konular

  1. 44. 2 eksen XY Joystick Modül ile servo kontrolü
    Konu Sahibi bolubeyi Forum Arduino Dersleri
    Cevap: 0
    Son Mesaj : 13.Eylül.2015, 02:24
  2. 43. 2 Eksen Güneş Paneli
    Konu Sahibi bolubeyi Forum Arduino Dersleri
    Cevap: 0
    Son Mesaj : 12.Eylül.2015, 17:38
  3. 39. 2 eksen hareket izleyen robot
    Konu Sahibi bolubeyi Forum Arduino Dersleri
    Cevap: 1
    Son Mesaj : 10.Ağustos.2015, 18:47
  4. 11. Mouse ile led kontrol
    Konu Sahibi bolubeyi Forum Arduino Dersleri
    Cevap: 0
    Son Mesaj : 13.Haziran.2015, 18:34
  5. Web üzerinden uzaktan kontrol
    Konu Sahibi WeBMasteR Forum Kurulum - İlk İşlemler
    Cevap: 0
    Son Mesaj : 19.Ekim.2013, 19:54

Bu Konu için Etiketler

Yetkileriniz

  • Konu Acma Yetkiniz Yok
  • Cevap Yazma Yetkiniz Yok
  • Eklenti Yükleme Yetkiniz Yok
  • Mesajınızı Değiştirme Yetkiniz Yok
  •  
Linux Hosting
Yasal Bildirim
Sitemizde paylaşım yapan tüm üyeler T.C.K 20. Madde ve 5651 Sayılı Kanun'un 4. maddesinin 2. fıkrasına göre kendi konu ve mesajlarından sorumludur. Webmaster.bbs.tr hakkında yapılacak olan hukuksal ve diğer şikayetler için iletişim bölümünden iletişime geçilmesi halinde site yönetimi tarafından gereken işlemler yapılacak ve ilgili kişilere/kurumlara/vekillerine bilgi verilecektir.
Sosyal Medya