C/C++

Stepper motor 28byj48 Shared Library

2 1355
swipon  
Edited by swipon at Jan 12, 2016 04:12

I'm trying to write a shared library to simlify the control of stepper motor 28byj48 you can download it from here:

https://www.dropbox.com/s/sd86oymhcrkp4j4/lib28byj48-0.1.tar.gz?dl=0

How to install:

  1. cd /usr/src
  2. wget <a href="https://www.dropbox.com/s/sd86oymhcrkp4j4/lib28byj48-0.1.tar.gz?dl=0">https://www.dropbox.com/s/sd86oymhcrkp4j4/lib28byj48-0.1.tar.gz?dl=0</a>
  3. tar xvfz lib28byj48-0.1.tar.gz
  4. cd lib28byj48-0.1
  5. make
Copy the Code


Example main.c :

  1. #include <lib28byj48.h>
  2. #include <wiringPi.h>
  3. #include <stdio.h>

  4. int main(void)
  5. {
  6. if (wiringPiSetup() == -1) /* it is already call from library an is possible that is unecessary*/
  7.     {
  8.         printf("Error: wiringPi setup failed.\n");
  9.         return 1;
  10.     } else {
  11.         /* change the arguments with your pins definition and data*/
  12.         initialize28BYJ48(short waitBeforeStart, short pin28BYJ48_blue, short pin28BYJ48_pink, short pin28BYJ48_yellow, short pin28BYJ48_orange);
  13.         move28BYJ48(short linearMovement, short direction); /* linearMovement 0 to 4095 (full circle) - direction is boolean 0 or 1*/
  14.     }
  15. return 0;
  16. }
Copy the Code


for compiling:
gcc -Wall -lwiringPi -lpthread -l28byj48 main.c


The motor Vcc would be connected with 2°pin and Motor Gnd to 25°pin the the 4 signal in GPIO pin (example pysichal pin 11-12-13-14 are enumerate in code 0,1,2,3)

Any correction or suggestion are welcome.
Luca

Edit: corrected the code for full work, add a little explain of connection and makefile now do also ldconfig programmaticaly.
Ok thank you!

The article you have shared here very awesome.
Potty Racers

You have to log in before you can reply Login | Sign Up

Points Rules