I have been using these small steppers for a couple different projects over the last 3 years. They are not very strong but work for light duty projects.
'28BYJ_48_12F683_ver092.gcb'2017/1/3'A program to Run a 4096 step geared step motor 28BYJ-48'actuallythisisdoingfullstepmodeinwhich2coilsareactiveataTime' so it only has 2048 steps/turn (seems like a couple less)'Anotherarraycouldbebuilttodoeighthalfsteps'The outputs run a ULN2003 like supplied by so many chinese suppliers'TheinputPortGPIO.4hasapushbutton'Setup: routine allows the operator to align the shaft on start up'MainLoop:routinerotatesthemotoronefullturn'If you change the MainLoop in line 44 to MainLoop2 then it'willdemoa5station/positionpattern'by Mike Otte'2013'Chip model#chip 12F683, 8 dim Full(5) Full(0) = b'00000110' Full(1) = b'00000011' Full(2) = b'00001001' Full(3) = b'00001100''SetthepindirectionsdirGPIO.0out'These are wired to the uln2003 inputsdir GPIO.1 outdir GPIO.2 outdir GPIO.5 outdir GPIO.4 IN 'pushbuttoninputDimpositionasWord'Could be integer if we go below 0 positionposition =0'InitializepositionroutineSetup:' let motor turn until operator Pushes Button at home Position If GPIO.4 = 1 Then StepCW 'waitforbuttonpushIfGPIO.4=0Thenposition=0wait500msgotoMainLoop2' to demo 5 position end if goto Setup'OneturnMainLoop,getherefrom3linesabove,line44?MainLoop:'wait for button push If GPIO.4 = 1 Then goto MainLoop StepTo(2040) 'oneturnposition=0'resets position counter for next move wait 500 ms 'GivestimeforbuttonreleaseifonlyafewstepsgotoMainLoop' Example2: of going to 5 different positions and waiting for the button to be pushed'ButtonisapulldownMainLoop2:IfGPIO.4=1ThengotoMainLoop2IfGPIO.4=0Thenstation++Ifstation>5thenstation=1wait500msgotonewstationendifgotoMainLoop2newstation:Selectcasestationcase1StepTo(500)'station position 1 wait 500 ms 'Givestimeforbuttonreleaseifonlyafewstepscase2StepTo(1500)'station position 2 wait 500 ms 'Givestimeforbuttonreleaseifonlyafewstepscase3StepTo(2500)'station position 3 wait 500 ms 'Givestimeforbuttonreleaseifonlyafewstepscase4StepTo(3000)'station position 4 wait 500 ms 'Givestimeforbuttonreleaseifonlyafewstepscase5StepTo(3100)'station position 5 wait 500 ms 'GivestimeforbuttonreleaseifonlyafewstepsendSelectgotoMainLoop2SubStepTo(newposasword)EnMotorDountilPosition=newposIfnewpos<positionthenStepCCWIfnewpos>positionthenStepCWloopDisEnMotorendsubSubEnMotordirGPIO.0outdirGPIO.1outdirGPIO.2outdirGPIO.5outendsubSubDisEnMotordirGPIO.0in'disables motor so it converves energy and don'theatupdirGPIO.1indirGPIO.2indirGPIO.5inendsubSubStepCWPosition++myStep=positionmod4thisStep=Full(myStep)GPIO.0=thisStep.0GPIO.1=thisStep.1GPIO.2=thisStep.2GPIO.5=thisStep.3wait2msendsubSubStepCCWPosition--myStep=positionmod4thisStep=Full(myStep)GPIO.0=thisStep.0GPIO.1=thisStep.1GPIO.2=thisStep.2GPIO.5=thisStep.3wait2msendsubEnd
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been using these small steppers for a couple different projects over the last 3 years. They are not very strong but work for light duty projects.
THANK YOU. Very nice example that others can learn from.
And, the first of the year!!!
:-)