Itan Fuentes Santamaria
Email: itan.fs@hotmail.com
Phone: 2227535416
so, what's a step motor? there are a kind of motors capable to move more precisely, or "step by step" each time a pulse pass through their internal coils, this can vary from big steps of 90° to small steps of 1.8°, what this means? it means that if you want to do a 360° turn, with the biggest steps you need to send 4 times a pulse, however, in the smallest steps you need to perform 200 times the pulse through the coils to complete a complete turn (360°). why we need this? because in many applications we need really precise movements, for example, in a CNC machine, and this motor are capable of do that :)
but if we want t use it, we can't just connect it to the arduino, it will be impossible for the microcontroler to move it, so we need something more, and that is a H-Bridge....so, what is that?
An H-bridge it's an electronic circuit capable to spin a motor in both ways, forward and backward, they are fully apply in robotics and as power converters. In these days we can find them as integrated circuits or we can build a H-bridge from 0 with passive components.
in these case we need a H-bridge because the microcontroller can't supply the enough current to move the motor with a proper torque.
this is the code i used to make a simple movement left to right
int mA=3; int mB=4; int mC=5; int mD=6;
void setup() {
pinMode(mA, OUTPUT);
pinMode(mB, OUTPUT);
pinMode(mC, OUTPUT);
pinMode(mD, OUTPUT);
pinMode(mE, OUTPUT);
pinMode(mF, OUTPUT);
pinMode(mG, OUTPUT);
pinMode(mH, OUTPUT);
//INICIAR EN PARO
digitalWrite(mA, LOW);
digitalWrite(mB, LOW);
digitalWrite(mC, LOW);
digitalWrite(mD, LOW);
digitalWrite(mE, LOW);
digitalWrite(mF, LOW);
digitalWrite(mG, LOW);
digitalWrite(mH, LOW);
Serial.begin(9600);
}
void izquierda(){
//paso 1
digitalWrite(mA, LOW);
digitalWrite(mB, HIGH);
digitalWrite(mC, HIGH);
digitalWrite(mD, LOW);
digitalWrite(mE, LOW);
digitalWrite(mF, HIGH);
digitalWrite(mG, HIGH);
digitalWrite(mH, LOW);
delay(1);
//paso 2
digitalWrite(mC, LOW);
digitalWrite(mD, HIGH);
digitalWrite(mG, LOW);
digitalWrite(mH, HIGH);
delay(1);
//paso 3
digitalWrite(mA, HIGH);
digitalWrite(mB, LOW);
digitalWrite(mE, HIGH);
digitalWrite(mF, LOW);
delay(1);
//paso 4
digitalWrite(mC, HIGH);
digitalWrite(mD, LOW);
digitalWrite(mG, HIGH);
digitalWrite(mH, LOW);
delay(1);
}//FIN izquierda
void derecha(){
//paso 1
digitalWrite(mA, HIGH);
digitalWrite(mB, LOW);
digitalWrite(mC, HIGH);
digitalWrite(mD, LOW);
digitalWrite(mE, HIGH);
digitalWrite(mF, LOW);
digitalWrite(mG, HIGH);
digitalWrite(mH, LOW);
delay(1);
//paso 2
digitalWrite(mC, LOW);
digitalWrite(mD, HIGH);
digitalWrite(mG, LOW);
digitalWrite(mH, HIGH);
delay(1);
//paso 3
digitalWrite(mA, LOW);
digitalWrite(mB, HIGH);
digitalWrite(mE, LOW);
digitalWrite(mF, HIGH);
delay(1);
//paso 4
digitalWrite(mC, HIGH);
digitalWrite(mD, LOW);
digitalWrite(mG, HIGH);
digitalWrite(mH, LOW);
delay(1);
}//FIN derecha
void loop() {
for(int i=0; i<100; i++) derecha();
delay (1000);
for(int i=0; i<100; i++) izquierda();
delay (1000);
}