Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

bauteile:trexdmc

Dies ist eine alte Version des Dokuments!




Motor Treiber TRex DMC

Ein Beispiel-Programm zum Ansteuern des TRex DMC durch die Arduino-Plattform:

/*
 The circuit: 
 * RX is digital pin 10 (connect to SO on TRex DMC)
 * TX is digital pin 11 (connect to SI on TRex DMC)
 
 
 */
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
 
void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
 
  // set the data rate for the SoftwareSerial port
  mySerial.begin(19200);
  // further Data-Query Commands: http://www.pololu.com/file/download/TReX_Commands_v1.2.pdf?file_id=0J1
  mySerial.write(0x83);
  delay(100);
  if(mySerial.read() == 1){
    Serial.println("Serial is in control!");
  }else{
    Serial.println("Serial ist not in control!");
  }
 
}
 
void loop() 
{  
  //Motor 1
  mySerial.write(0xC2); //forward motor 1
  mySerial.write(20); //Speedvalue from 0 to 127
  //Motor 2
  mySerial.write(0xCA); //forward motor 2
  mySerial.write(20); //Speedvalue from 0 to 127
}
bauteile/trexdmc.1389705797.txt.gz · Zuletzt geändert: 2016/01/21 12:45 (Externe Bearbeitung)