Skip to content

Instantly share code, notes, and snippets.

@IdrisCytron
Last active June 14, 2017 15:03
Show Gist options
  • Save IdrisCytron/24d0419604987529f39f21d93ea3cb65 to your computer and use it in GitHub Desktop.
Save IdrisCytron/24d0419604987529f39f21d93ea3cb65 to your computer and use it in GitHub Desktop.
Cytron_Shield3AMotor examples
/*
This example shows how to move G15 knob to certain angle with different speed.
Function:
control(motor1Speed, motor2Speed); // Value for motor1Speed and motor2Speed range
// is from -100 (max CCW) to 100 (max CW)
Product page:
3A Motor Driver Shield: https://www.cytron.com.my/p-shield-3amotor
CT-UNO: http://www.cytron.com.my/p-ct-uno
Original written by:
20/05/17 Idris, Cytron Technologies
*/
#include "Cytron_Shield3AMotor.h"
Shield3AMotor motor(SIGNED_MAGNITUDE);
signed int motor1Speed, motor2Speed;
void setup()
{
}
void loop()
{
// Control motor1 speed
// Value range from -100 (max CCW) to 100 (max CW)
// -ve value represent opposite direction to +ve value
for(motor1Speed = 0; motor1Speed < 100; motor1Speed++) {
motor.control(motor1Speed, 0);
delay(100);
}
for(motor1Speed = 100; motor1Speed > -100; motor1Speed--) {
motor.control(motor1Speed, 0);
delay(100);
}
for(motor1Speed = -100; motor1Speed < 0; motor1Speed++) {
motor.control(motor1Speed, 0);
delay(100);
}
// Control motor2 speed motor
// Value range from -100 (max CCW) to 100 (max CW)
// -ve value represent opposite direction to +ve value
for(motor2Speed = 0; motor2Speed < 100; motor2Speed++) {
motor.control(0, motor2Speed);
delay(100);
}
for(motor2Speed = 100; motor2Speed > -100; motor2Speed--) {
motor.control(0, motor2Speed);
delay(100);
}
for(motor2Speed = -100; motor2Speed < 0; motor2Speed++) {
motor.control(0, motor2Speed);
delay(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment