lorzangas porafor / Mbed 2 deprecated motorpaso

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 BusOut myleds(LED1, LED2, LED3, LED4);
00004 BusOut motor(p10, p11, p12, p13);
00005 
00006 /* Paso p10 p11 p12 p13
00007      1   1   0   1   0
00008      2   0   1   1   0
00009      3   0   1   0   1
00010      4   1   0   0   1
00011      */
00012 int tiempo = 12000;//tiempo en us (tiempo entre pasos) nos da la velocidad 
00013 int main() {
00014     while(1) {
00015         for (int s = 0; s < 120 ; s +=1) {//el 120 indica 120*4 pasos, en mi motor de 48 pasos 10 vueltas
00016         motor = (0xA); //1010
00017         wait_us(tiempo);
00018         motor = (0x6);//0110
00019         wait_us(tiempo);
00020         motor = (0x5);//0101
00021         wait_us(tiempo);
00022         motor = (0x9);//1001
00023         wait_us(tiempo);
00024         }
00025         wait(2);
00026         for (int s = 0; s < 120 ; s +=1) {//ahora en sentido contrario
00027         motor = (0x9);//1001
00028         wait_us(tiempo);
00029         motor = (0x5);//0101
00030         wait_us(tiempo);
00031         motor = (0x6);//0110
00032         wait_us(tiempo);
00033         motor = (0xA);//1010
00034         wait_us(tiempo);
00035         }
00036         wait(2);
00037    }
00038 }