takeup/ino/demo/demo.ino

67 lines
1.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Prototype
* Arduino Duemilanove
* L298N shield V03
* https://traction-design.be/home/arduino-l298n-shield-v03-from-flamingoeda-com/
*
* Pin 13 = motor A or coil A +
* Pin 12 = motor A or coil A
* Pin 11 = motor B or coil B +
* Pin 10 = motor A or coil A enable
* Pin 9 = motor B or coil B enable
* Pin 8 = motor B or coil B
**/
#define Apos 13
#define Aneg 12
#define Aenable 10
void setup() {
pinMode(Apos, OUTPUT);
pinMode(Aneg, OUTPUT);
pinMode(Aenable, OUTPUT);
}
void loop() {
clockwise();
set_speed(250);
delay(5000);
brake();
delay(2000);
counter_clockwise();
set_speed(250);
delay(5000);
brake();
delay(2000);
}
//input value from 0 to 255
void set_speed (int val){
analogWrite(Aenable, val);
}
void clockwise(){
digitalWrite(Apos, HIGH);
digitalWrite(Aneg, LOW);
}
void counter_clockwise(){
digitalWrite(Apos, LOW);
digitalWrite(Aneg, HIGH);
}
void brake (){
digitalWrite(Aenable, LOW);
}
/**
* Vex = higher voltage that can power the motor and/or the shield as well as the Arduino if wanted
* 5V = Must be a clean 5V that can power the Arduino and shield, and if wanted also the motor itself
* GND = ass always, the ground of everything
* B- = Connection of the first motor or first winding of the stepper motor
* B+ = Connection of the first motor or first winding of the stepper motor
* A- = Connection of the second motor or second winding of the stepper motor
* A+ = Connection of the second motor or second winding of the stepper motor
**/