Hi to all…
I recently purchased and assembled the KA03 kit; apart from mounting the dual H bridge IC this was a breeze… that took all my soldering skills…
anyway, I got it working for a plain DC motor; I haven’t tried the stepper motor option yet…
here is my code…
===
//
// KA03/VMA03 Velleman kit example code; somewhat cleaned up and explained…
//
// active Arduino pins for control; these numbers should correspond with the onboard jumper settings, for each motor…
// this makes it possible to dedicate this shield to free Arduino output ports when combining shields…
// we can actually run 2 motors (A on shield output pins 1 and 2, B on 3 and 4) in this sketch…
// we assume 1/3 to be + and 2/4 - to the DC motors…
int pwm_a = 3; // PWM control { jumpers 3 | 5 | 6 } for motor A…
int dir_a = 2; // direction control { 2 | 4 | 7 } for motor A…
int pwm_b = 9; // PWM control { 9 | 10 | 11 } for motor B…
int dir_b = 8; // direction control { 8 | 12 | 13 } for motor B…
boolean dirFlag_a; // false = clockwise, true = reverse; motor A…
boolean dirFlag_b; // motor B…
void setup() {
pinMode(pwm_a, OUTPUT); // Set control pins to be outputs for motor A…
pinMode(dir_a, OUTPUT); // …
pinMode(pwm_b, OUTPUT); // Set control pins to be outputs for motor B…
pinMode(dir_b, OUTPUT); // …
dirFlag_a = false; // we initially run A clockwise…
dirFlag_b = true; // B counter clockwise…
runMotor(dirFlag_a,“init”,pwm_a,dir_a); // init run A in current direction: the DIR LED should turn up green…
runMotor(dirFlag_b,“init”,pwm_b,dir_b); // init run B in current direction: the DIR LED should turn up red…
}
void loop() {
runMotor(dirFlag_a,“run”,pwm_a,dir_a); // run A in current direction, and reverse: the DIR LED should turn up alternating green/red…
dirFlag_a = !dirFlag_a; // toggle direction flag…
runMotor(dirFlag_b,“run”,pwm_b,dir_b); // run B in current direction, and reverse: the DIR LED should turn up alternating green/red…
dirFlag_b = !dirFlag_b; // toggle direction flag…
}
void runMotor(boolean dirF, String mode, int pwm, int dir) {
if (dirF == false) digitalWrite(dir, LOW);
else digitalWrite(dir, HIGH);
if (mode.equals(“init”)) { // initial run…
analogWrite(pwm, 255); delay(2000); // set motor to jumpstart at 255/255 = 100% duty cycle (max. speed)
analogWrite(pwm, 0); delay(1000); // stop motor, after 2 seconds…
}
else { // run mode…
// we do serial runs of minimum speed (63 = 25%), half speed (127 = 50%) and full speed (255 = 100%)...
//
// please note, that at minimum speed output performance may differ, depending on the type of motor...
// also the DIR LEDS vary in brightness/colour, depending on the output signal and motorload; brighter = higher speed...
delay(2000); // adds up to 3 seconds, between alternating runs...
for (int i = 0; i < 3; i++) {
analogWrite(pwm, pow(2,i+6)-1); delay(1500); // switch motor on at set speed; allow for catching up momentum...
analogWrite(pwm, 0); delay(1000); // switch off...
}
}
}
===
this works for me, for now… enjoy…