Lezzetli Robot Tarifleri Sosyal'e Hoş Geldiniz.. Devamı..

Giriş Yap Üye Ol


Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
A4988 İle kodlanmış Bir Programlı ULN2003A Sürücüsüne göre kodlama
#1
Yukarıda da belirttiğim gibi a4988 için yazılan kodları uln2003a için değiştirmek istiyorum mümkün müdür ? delay kısmında ekstra birşey yapmam gerekir mi? Altta 1.si A 4988 2.si düzenlemeye çalıştığım kod.
 
Kod:
// based on Dan Thompson 2008 http://danthompsonsblog.blogspot.com/
// modified by MagWeb 02.2009

// MURAT KIZILKAYA tarafından değiştirildi HAZİRAN 2015 // MODIFIED BY MK, 06.15
// twitter.com/muratkizilk
// instagram.com/muratkizilk

// TÜRK İŞİ EKİBİ - NTV
// facebook.com/ntv.turkisi
// twitter.com/ntv_turkisi
// instagram.com/ntv_turkisi
// Daha fazla bilgi için ->> www.turkisi.tv
//3d LAZER tarayıcı KODU
//




////////////////////////////////////////////////////////
//Arduino Stepper Motor skecth listening to COM Port
//for use with the EasyDriver 3.1 and DAVID-laserscanner
////////////////////////////////////////////////////////


// based on Dan Thompson 2008 http://danthompsonsblog.blogspot.com/
// modified by MagWeb 02.2009
// Added : Pushbutton to start a single circle or to stop it while it is running
// Added : Endswitch to get zero-value of motion
// Added : LED enlighted while motor moves forward
// Added : Potentiometer to controll motor speed by hand
// Added : second EasyDriver to controll a turntable

// For all the Easydriver v.3 product details http://schmalzhaus.com/EasyDriver/
// For all the DAVID-laserscanner product details http://www.david-laserscanner.com

// Executes a reference motion towards endswitch at character "i"
// Runs scanning circle when you send "g" to the serial port,
// Stops scanning circle when you send "s" to the serial port,
// Switches on light when you send "l" to the serial port,
// Switches off light when you send "d" to the serial port,
// Turns a turntable at 45¡ if you send "t" to the serial port (standard 1.8¡/step),

//Use this code at your own risk and have fun




// Pins
int val = 0;           // stores the state of the BUTTON pin
int LED = 11;           // names pin 9 as LED (placeholder for the laser)
int BUTTON = 7;        // names pin 7 as BUTTON
int END = 8;           // names pin 8 as the endswitch
int LIGHT = 2;         // names pin 2 as the lightswitch
int potpin = 2;        // names pin 2 as "potpin"
int dirpin = 3;        // names pin 3 as "dirpin" -Stepperdirection laser
int steppin = 4;      // names pin 12 as "steppin" -Steppersteps laser
int ttdir = 5;          // names pin 4 as "dirpin" -Stepperdirection turntable
int ttstep = 6;        // names pin 5 as "dirpin" -Steppersteps turntable
//variables
int temp = 0;          // Stores the speed value. The smaller the faster
long range = 300;     // Stores how many steps will be made in total -Stepper laser
int ttrange = 400;      // Stores how many steps will be made in total -Stepper Turntable
int incomingByte = 0;    // for incoming serial data
int old_val = 0;
int state = 0;



void setup() {
 Serial.begin(9600);    // opens serial communication

 pinMode(dirpin, OUTPUT);  // Sets pins to in or out modes
 pinMode(steppin, OUTPUT); //
 pinMode(LED, OUTPUT);     //
 pinMode(BUTTON, INPUT);   //
 pinMode(LIGHT, OUTPUT);   //
 pinMode(END, INPUT);      //
 pinMode(ttdir, OUTPUT);   //
 pinMode(ttstep, OUTPUT);  //
 }


void loop() {
 val=digitalRead(BUTTON);   // read Button input value and store it
 if ((val == HIGH) && (old_val == LOW)) {
   state = 1 - state;
   delay(10);
 }
 
 old_val = val;
 
 
  if (Serial.available() > 0) {
        // read the incoming byte:
        incomingByte = Serial.read();

        // say what you got:
        Serial.print("I received: ");
        Serial.println(incomingByte);
               
    }
 delay(100);
 
 
 
 if (incomingByte == 108) {        // switches on light when "l" is sent by DAVID
   digitalWrite(LED, HIGH);
   incomingByte = 0;
 }
 
 if(incomingByte == 100) {        //switches off light when "d" is sent by DAVID
   digitalWrite(LED, LOW);
   incomingByte = 0;
 }


 if (incomingByte == 112) {        // switches on light when "l" is sent by DAVID
   digitalWrite(LIGHT, HIGH);
   incomingByte = 0;
 }
 
 if(incomingByte == 113) {        //switches off light when "d" is sent by DAVID
   digitalWrite(LIGHT, LOW);
   incomingByte = 0;
 }


 
if (incomingByte == 116) {             // when "t" was sent by DAVID>> turntable travel
 digitalWrite(ttdir, LOW);              // Changes direction
 int i;
     delay(100);

    //////////Serial.println("in motion");           // sends "in motion" to PC
     for (i = 0; i<ttrange+1; i++) {        // pulse
       digitalWrite(ttstep, HIGH);          //   :
       delayMicroseconds(1300);              //   :
       digitalWrite(ttstep, LOW);           //   :
       delayMicroseconds(1300);              // pulse
       
       if (i == ttrange) {                  //stop
         break;
       }
       incomingByte = 0;
     }
 }    
   
   
   
 
 
 if (incomingByte == 105) {             // when "i" was sent by DAVID>> initial travel
 digitalWrite(dirpin, LOW);              // Changes direction
 int i;
     delay(100);

    //////////Serial.println("INITIAL");         // sends "INITIAL" to PC
     for (i = 0; i<range; i++) {        // pulse
       digitalWrite(steppin, HIGH);     //   :
       delayMicroseconds(100);          //   :
       digitalWrite(steppin, LOW);      //   :
       delayMicroseconds(100);          // pulse
       int end = digitalRead (END);
       if (end == HIGH) {               // endswitch
         break;
       }
     }
 }
 
 if ( state == 1 || incomingByte == 103) {                    // If button is pressed
   int i;                              // sets counter of pulses
   temp = 50+analogRead(potpin);     // reads the poti-value and sets speed
   digitalWrite(dirpin, HIGH);         // should be clockwise motormovement
   delay(50);
  //////////Serial.println("SCANNING");               // sends "SCANNING" to PC

   for (i = 0; i<range; i++) {         // pulse
     digitalWrite(steppin, HIGH);      //   :
     delay(temp);          //   :
     digitalWrite(steppin, LOW);       //   :
     delay(temp);          // pulse
     //if (i > 100)  {                   // Waits 100 pulses till LED switches on
       digitalWrite(LED, HIGH);
     //}
     temp = 50+analogRead(potpin);    // reads again the poti-value and sets speed
     incomingByte = Serial.read();
     val = digitalRead (BUTTON);
      if (incomingByte == 115 || i == range-1 || val == HIGH) { // when "s" was sent by DAVID or max range>> stop and backtravel
         digitalWrite(dirpin, LOW);           // Changes direction
         digitalWrite(LED, LOW);              // switch off LED
         
         delay(100);

         //////////Serial.println("BACK");              // sends "BACK" to PC
         for (i = 0; i<range; i++) {      // pulse
         digitalWrite(steppin, HIGH);     //   :
         delay(20);          //   :
         digitalWrite(steppin, LOW);      //   :
         delay(20);          // pulse
         int end = digitalRead (END);  // reads the endswitch

         if (end == HIGH) {            // stop if endswitch reached
           digitalWrite(LED, LOW);       // switch off LED
           i = range;
           incomingByte = 0;
           break;
           }      
         }          
       }        
    }      
delay(100);
 }
val = LOW;
incomingByte = 0;
state = 0;
}

Kod:
// based on Dan Thompson 2008 http://danthompsonsblog.blogspot.com/
// modified by MagWeb 02.2009

// MURAT KIZILKAYA tarafından değiştirildi HAZİRAN 2015 // MODIFIED BY MK, 06.15
// twitter.com/muratkizilk
// instagram.com/muratkizilk

// TÜRK İŞİ EKİBİ - NTV
// facebook.com/ntv.turkisi
// twitter.com/ntv_turkisi
// instagram.com/ntv_turkisi
// Daha fazla bilgi için ->> www.turkisi.tv
//3d LAZER tarayıcı KODU
//




////////////////////////////////////////////////////////
//Arduino Stepper Motor skecth listening to COM Port
//for use with the EasyDriver 3.1 and DAVID-laserscanner
////////////////////////////////////////////////////////


// based on Dan Thompson 2008 http://danthompsonsblog.blogspot.com/
// modified by MagWeb 02.2009
// Added : Pushbutton to start a single circle or to stop it while it is running
// Added : Endswitch to get zero-value of motion
// Added : LED enlighted while motor moves forward
// Added : Potentiometer to controll motor speed by hand
// Added : second EasyDriver to controll a turntable

// For all the Easydriver v.3 product details http://schmalzhaus.com/EasyDriver/
// For all the DAVID-laserscanner product details http://www.david-laserscanner.com

// Executes a reference motion towards endswitch at character "i"
// Runs scanning circle when you send "g" to the serial port,
// Stops scanning circle when you send "s" to the serial port,
// Switches on light when you send "l" to the serial port,
// Switches off light when you send "d" to the serial port,
// Turns a turntable at 45¡ if you send "t" to the serial port (standard 1.8¡/step),

//Use this code at your own risk and have fun




// Pins
int val = 0;           // stores the state of the BUTTON pin
int LED = 3;           // names pin 9 as LED (placeholder for the laser)
int BUTTON = 13;        // names pin 7 as BUTTON
int END = 12;           // names pin 8 as the endswitch
int LIGHT = 2;         // names pin 2 as the lightswitch
int potpin = A2;        // names pin 2 as "potpin"
//int dirpin = 3;        // names pin 3 as "dirpin" -Stepperdirection laser
//int steppin = 4;      // names pin 12 as "steppin" -Steppersteps laser
//int ttdir = 5;          // names pin 4 as "dirpin" -Stepperdirection turntable
//int ttstep = 6;        // names pin 5   as "dirpin" -Steppersteps turntable
//variables
int temp = 0;          // Stores the speed value. The smaller the faster
long range = 350;     // Stores how many steps will be made in total -Stepper laser
int ttrange = 512;      // Stores how many steps will be made in total -Stepper Turntable
int incomingByte = 0;  // for incoming serial data
int old_val = 0;
int state = 0;
const int tmotorPin1 =4 ;
const int tmotorPin2 = 5;  
const int tmotorPin3 = 6;
const int tmotorPin4 = 7;
const int lmotorPin1 =8 ;
const int lmotorPin2 = 9;
const int lmotorPin3 = 10;
const int lmotorPin4 = 11;

int bekleme= 2;

void lmadim1() {
digitalWrite(lmotorPin1, HIGH);
digitalWrite(lmotorPin2, LOW);
digitalWrite(lmotorPin3, LOW);
digitalWrite(lmotorPin4, LOW);
delay(bekleme);
}

  void lmadim2() {
digitalWrite(lmotorPin1, LOW);
digitalWrite(lmotorPin2, HIGH);
digitalWrite(lmotorPin3, LOW);
digitalWrite(lmotorPin4, LOW);
delay(bekleme);
}

  void lmadim3() {
digitalWrite(lmotorPin1, LOW);
digitalWrite(lmotorPin2, LOW);
digitalWrite(lmotorPin3, HIGH);
digitalWrite(lmotorPin4, LOW);
delay(bekleme);
}

  void lmadim4() {
digitalWrite(lmotorPin1, LOW);
digitalWrite(lmotorPin2, LOW);
digitalWrite(lmotorPin3, LOW);
digitalWrite(lmotorPin4, HIGH);
delay(bekleme);
}
 void lmstop() {
 digitalWrite(lmotorPin1, LOW);
 digitalWrite(lmotorPin2, LOW);
 digitalWrite(lmotorPin3, LOW);
 digitalWrite(lmotorPin4, LOW);
 delay(bekleme);}
 void tmadim1() {
digitalWrite(tmotorPin1, HIGH);
digitalWrite(tmotorPin2, LOW);
digitalWrite(tmotorPin3, LOW);
digitalWrite(tmotorPin4, LOW);
delay(bekleme);
}

void tmadim2() {
digitalWrite(tmotorPin1, LOW);
digitalWrite(tmotorPin2, HIGH);
digitalWrite(tmotorPin3, LOW);
digitalWrite(tmotorPin4, LOW);
delay(bekleme);
}

void tmadim3() {
digitalWrite(tmotorPin1, LOW);
digitalWrite(tmotorPin2, LOW);
digitalWrite(tmotorPin3, HIGH);
digitalWrite(tmotorPin4, LOW);
delay(bekleme);
}

void tmadim4() {
digitalWrite(tmotorPin1, LOW);
digitalWrite(tmotorPin2, LOW);
digitalWrite(tmotorPin3, LOW);
digitalWrite(tmotorPin4, HIGH);
delay(bekleme);
}
void tmstop() {
 digitalWrite(tmotorPin1, LOW);
 digitalWrite(tmotorPin2, LOW);
 digitalWrite(tmotorPin3, LOW);
 digitalWrite(tmotorPin4, LOW);
 delay(bekleme);
 }
      void tmotorileri() {
   tmadim1();
   tmadim2();
   tmadim3();
   tmadim4(); }
     void tmotorgeri() {
   tmadim4();
   tmadim3();
   tmadim2();
   tmadim1(); }
 void lmotorileri() {
     lmadim1();
     lmadim2();
     lmadim3();
     lmadim4(); }
 void lmotorgeri() {
     lmadim4();
     lmadim3();
     lmadim2();
     lmadim1(); }

void setup() {
 Serial.begin(9600);    // opens serial communication

//  pinMode(dirpin, OUTPUT);  // Sets pins to in or out modes
//  pinMode(steppin, OUTPUT); //
 pinMode(LED, OUTPUT);     //
 pinMode(BUTTON, INPUT);   //
 pinMode(LIGHT, OUTPUT);   //
 pinMode(END, INPUT);      //
//  pinMode(ttdir, OUTPUT);   //
//  pinMode(ttstep, OUTPUT);  //
pinMode(lmotorPin1, OUTPUT);
pinMode(lmotorPin2, OUTPUT);
pinMode(lmotorPin3, OUTPUT);
pinMode(lmotorPin4, OUTPUT);
pinMode(tmotorPin1, OUTPUT);
pinMode(tmotorPin2, OUTPUT);
pinMode(tmotorPin3, OUTPUT);
pinMode(tmotorPin4, OUTPUT);
 }


void loop() {
 val=digitalRead(BUTTON);   // read Button input value and store it
 if ((val == HIGH) && (old_val == LOW)) {
   state = 1 - state;
   delay(10);
 }
 
 old_val = val;
 
 
  if (Serial.available() > 0) {
   // read the incoming byte:
   incomingByte = Serial.read();

   // say what you got:
   Serial.print("I received: ");
   Serial.println(incomingByte);
               
 }
 delay(100);
 
 
 
 if (incomingByte == 108) {        // switches on light when "l" is sent by DAVID
   digitalWrite(LED, HIGH);
   incomingByte = 0;
 }
 
 if(incomingByte == 100) {        //switches off light when "d" is sent by DAVID
   digitalWrite(LED, LOW);
   incomingByte = 0;
 }


 if (incomingByte == 112) {        // switches on light when "l" is sent by DAVID
   digitalWrite(LIGHT, HIGH);
   incomingByte = 0;
 }
 
 if(incomingByte == 113) {        //switches off light when "d" is sent by DAVID
   digitalWrite(LIGHT, LOW);
   incomingByte = 0;
 }


 
if (incomingByte == 116) {             // when "t" was sent by DAVID>> turntable travel
 tmstop();              // Changes direction
 int i;
     delay(100);

    //////////Serial.println("in motion");           // sends "in motion" to PC
     for (i = 0; i<ttrange+1; i++) {        // pulse
        bekleme=5;
        tmotorileri();          
        bekleme=5;            
       tmstop();        
                  // pulse
       
       if (i == ttrange) {                  //stop
         break;
       }
       incomingByte = 0;
     }
 }    
   
   
   
 
 
 if (incomingByte == 105) {             // when "i" was sent by DAVID>> initial travel
 lmstop();              // Changes direction
 int i;
     delay(100);

    //////////Serial.println("INITIAL");         // sends "INITIAL" to PC
     for (i = 0; i<range; i++) {        // pulse
      bekleme=5;
      lmotorileri();     //   :
      bekleme=5;          //   :
       lmstop()  ;    //   :
                 
       int end = digitalRead (END);
       if (end == HIGH) {               // endswitch
         break;
       }
     }
 }
 
 if ( state == 1 || incomingByte == 103) {                    // If button is pressed
   int i;                              // sets counter of pulses
   temp = 50+analogRead(potpin);     // reads the poti-value and sets speed
   bekleme=2;
   lmotorgeri();         // should be clockwise motormovement

  //////////Serial.println("SCANNING");               // sends "SCANNING" to PC

   for (i = 0; i<range; i++) {         // pulse
     lmotorileri();      //   :
     bekleme=2;          //   :
    lmstop();       //   :
    bekleme=2;          // pulse
     //if (i > 100)  {                   // Waits 100 pulses till LED switches on
       digitalWrite(LED, HIGH);
     //}
     temp = analogRead(potpin);    // reads again the poti-value and sets speed
     incomingByte = Serial.read();
     val = digitalRead (BUTTON);
      if (incomingByte == 115 || i == range-1 || val == HIGH) { // when "s" was sent by DAVID or max range>> stop and backtravel
        bekleme=temp;
         lmstop();           // Changes direction
         digitalWrite(LED, LOW);              // switch off LED
         
         delay(100);

         //////////Serial.println("BACK");              // sends "BACK" to PC
         for (i = 0; i<range; i++) {      // pulse
       bekleme=4;
        lmotorileri();      ;          //   : //   :
        bekleme=4;
          delay(20);      //   :
                   // pulse
         int end = digitalRead (END);  // reads the endswitch

         if (end == HIGH) {            // stop if endswitch reached
           digitalWrite(LED, LOW);       // switch off LED
           i = range;
           incomingByte = 0;
           break;
           }      
         }          
       }        
    }      
delay(100);
 }
val = LOW;
incomingByte = 0;
state = 0;
}
[img=1267x1080]http://turkisi.programlar.ntv.com.tr/wp-content/uploads/2015/04/3d_laser_scanner_devre_semasi.jpg[/img]
Asıl sorum a4988 deki delay kısımı ben uln2003 de nasıl yazabilirim ?
Ara
Cevapla


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  infra girişlere göre koşullu çıkış alma xxerdemxx 0 79 09-03-2018, Saat: 02:16
Son Yorum: xxerdemxx
  button okuma ve sayı farkına göre işlem yapma kaan ekiz 0 87 16-02-2018, Saat: 23:15
Son Yorum: kaan ekiz
  HC-05 Bluetooth modülündeki kodlama Dogu 1 435 21-04-2017, Saat: 01:30
Son Yorum: z1rqdym
  Pota Gore Artip Azalan Bar Ozan Bayramoglu 0 232 01-03-2017, Saat: 00:30
Son Yorum: Ozan Bayramoglu

Hızlı Menü:


Konuyu Okuyanlar:
1 Ziyaretçi