Added arduino libs
هذا الالتزام موجود في:
@@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
* THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTY AND SUPPORT
|
||||
* IS APPLICABLE TO THIS SOFTWARE IN ANY FORM. CYTRON TECHNOLOGIES SHALL NOT,
|
||||
* IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL
|
||||
* DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
********************************************************************************
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This example shows how to drive a motor using the PWM and DIR pins.
|
||||
* This example only shows how to drive a single motor for simplicity.
|
||||
* For dual channel motor driver, both channel work the same way.
|
||||
*
|
||||
*
|
||||
* CONNECTIONS:
|
||||
*
|
||||
* Arduino D3 - Motor Driver PWM Input
|
||||
* Arduino D4 - Motor Driver DIR Input
|
||||
* Arduino GND - Motor Driver GND
|
||||
*
|
||||
*
|
||||
* AUTHOR : Kong Wai Weng
|
||||
* COMPANY : Cytron Technologies Sdn Bhd
|
||||
* WEBSITE : www.cytron.io
|
||||
* EMAIL : support@cytron.io
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CytronMotorDriver.h"
|
||||
|
||||
|
||||
// Configure the motor driver.
|
||||
CytronMD motor(PWM_DIR, 3, 4); // PWM = Pin 3, DIR = Pin 4.
|
||||
|
||||
|
||||
// The setup routine runs once when you press reset.
|
||||
void setup() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// The loop routine runs over and over again forever.
|
||||
void loop() {
|
||||
motor.setSpeed(128); // Run forward at 50% speed.
|
||||
delay(1000);
|
||||
|
||||
motor.setSpeed(255); // Run forward at full speed.
|
||||
delay(1000);
|
||||
|
||||
motor.setSpeed(0); // Stop.
|
||||
delay(1000);
|
||||
|
||||
motor.setSpeed(-128); // Run backward at 50% speed.
|
||||
delay(1000);
|
||||
|
||||
motor.setSpeed(-255); // Run backward at full speed.
|
||||
delay(1000);
|
||||
|
||||
motor.setSpeed(0); // Stop.
|
||||
delay(1000);
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
/*******************************************************************************
|
||||
* THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTY AND SUPPORT
|
||||
* IS APPLICABLE TO THIS SOFTWARE IN ANY FORM. CYTRON TECHNOLOGIES SHALL NOT,
|
||||
* IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL
|
||||
* DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
********************************************************************************
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This example shows how to drive 2 motors using the PWM and DIR pins with
|
||||
* 2-channel motor driver.
|
||||
*
|
||||
*
|
||||
* CONNECTIONS:
|
||||
*
|
||||
* Arduino D3 - Motor Driver PWM 1 Input
|
||||
* Arduino D4 - Motor Driver DIR 1 Input
|
||||
* Arduino D9 - Motor Driver PWM 2 Input
|
||||
* Arduino D10 - Motor Driver DIR 2 Input
|
||||
* Arduino GND - Motor Driver GND
|
||||
*
|
||||
*
|
||||
* AUTHOR : Kong Wai Weng
|
||||
* COMPANY : Cytron Technologies Sdn Bhd
|
||||
* WEBSITE : www.cytron.io
|
||||
* EMAIL : support@cytron.io
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CytronMotorDriver.h"
|
||||
|
||||
|
||||
// Configure the motor driver.
|
||||
CytronMD motor1(PWM_DIR, 3, 4); // PWM 1 = Pin 3, DIR 1 = Pin 4.
|
||||
CytronMD motor2(PWM_DIR, 9, 10); // PWM 2 = Pin 9, DIR 2 = Pin 10.
|
||||
|
||||
|
||||
// The setup routine runs once when you press reset.
|
||||
void setup() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// The loop routine runs over and over again forever.
|
||||
void loop() {
|
||||
motor1.setSpeed(128); // Motor 1 runs forward at 50% speed.
|
||||
motor2.setSpeed(-128); // Motor 2 runs backward at 50% speed.
|
||||
delay(1000);
|
||||
|
||||
motor1.setSpeed(255); // Motor 1 runs forward at full speed.
|
||||
motor2.setSpeed(-255); // Motor 2 runs backward at full speed.
|
||||
delay(1000);
|
||||
|
||||
motor1.setSpeed(0); // Motor 1 stops.
|
||||
motor2.setSpeed(0); // Motor 2 stops.
|
||||
delay(1000);
|
||||
|
||||
motor1.setSpeed(-128); // Motor 1 runs backward at 50% speed.
|
||||
motor2.setSpeed(128); // Motor 2 runs forward at 50% speed.
|
||||
delay(1000);
|
||||
|
||||
motor1.setSpeed(-255); // Motor 1 runs backward at full speed.
|
||||
motor2.setSpeed(255); // Motor 2 runs forward at full speed.
|
||||
delay(1000);
|
||||
|
||||
motor1.setSpeed(0); // Motor 1 stops.
|
||||
motor2.setSpeed(0); // Motor 2 stops.
|
||||
delay(1000);
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
/*******************************************************************************
|
||||
* THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTY AND SUPPORT
|
||||
* IS APPLICABLE TO THIS SOFTWARE IN ANY FORM. CYTRON TECHNOLOGIES SHALL NOT,
|
||||
* IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL
|
||||
* DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
********************************************************************************
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This example shows how to drive 2 motors using 4 PWM pins (2 for each motor)
|
||||
* with 2-channel motor driver.
|
||||
*
|
||||
*
|
||||
* CONNECTIONS:
|
||||
*
|
||||
* Arduino D3 - Motor Driver PWM 1A Input
|
||||
* Arduino D9 - Motor Driver PWM 1B Input
|
||||
* Arduino D10 - Motor Driver PWM 2A Input
|
||||
* Arduino D11 - Motor Driver PWM 2B Input
|
||||
* Arduino GND - Motor Driver GND
|
||||
*
|
||||
*
|
||||
* AUTHOR : Kong Wai Weng
|
||||
* COMPANY : Cytron Technologies Sdn Bhd
|
||||
* WEBSITE : www.cytron.io
|
||||
* EMAIL : support@cytron.io
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CytronMotorDriver.h"
|
||||
|
||||
|
||||
// Configure the motor driver.
|
||||
CytronMD motor1(PWM_PWM, 3, 9); // PWM 1A = Pin 3, PWM 1B = Pin 9.
|
||||
CytronMD motor2(PWM_PWM, 10, 11); // PWM 2A = Pin 10, PWM 2B = Pin 11.
|
||||
|
||||
|
||||
// The setup routine runs once when you press reset.
|
||||
void setup() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// The loop routine runs over and over again forever.
|
||||
void loop() {
|
||||
motor1.setSpeed(128); // Motor 1 runs forward at 50% speed.
|
||||
motor2.setSpeed(-128); // Motor 2 runs backward at 50% speed.
|
||||
delay(1000);
|
||||
|
||||
motor1.setSpeed(255); // Motor 1 runs forward at full speed.
|
||||
motor2.setSpeed(-255); // Motor 2 runs backward at full speed.
|
||||
delay(1000);
|
||||
|
||||
motor1.setSpeed(0); // Motor 1 stops.
|
||||
motor2.setSpeed(0); // Motor 2 stops.
|
||||
delay(1000);
|
||||
|
||||
motor1.setSpeed(-128); // Motor 1 runs backward at 50% speed.
|
||||
motor2.setSpeed(128); // Motor 2 runs forward at 50% speed.
|
||||
delay(1000);
|
||||
|
||||
motor1.setSpeed(-255); // Motor 1 runs backward at full speed.
|
||||
motor2.setSpeed(255); // Motor 2 runs forward at full speed.
|
||||
delay(1000);
|
||||
|
||||
motor1.setSpeed(0); // Motor 1 stops.
|
||||
motor2.setSpeed(0); // Motor 2 stops.
|
||||
delay(1000);
|
||||
}
|
المرجع في مشكلة جديدة
حظر مستخدم