资源简介
esp8266、 esp32、可用的28byj、20byj、24byj五线四相步进电机库文件

代码片段和文件信息
/*
* Stepper2.h - BYJ48 stepper motor library for Wiring/Arduino - Version 0.0.1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not write to the Free Software
* Foundation Inc. 51 Franklin St Fifth Floor Boston MA 02110-1301 USA
*
* The circuits can be found at
*
* https://github.com/udivankin/Stepper2
*/
#include “Arduino.h“
#include “Stepper2.h“
const int microsInSecond = 1000L * 1000L;
const int microsInMinute = 60L * microsInSecond;
// Maximum steps per second
const int maxHz = 1000;
// Approx steps count to make a full turn
const int stepsPerFullTurn = 4096;
// Number of steps to make a rev of internal motor
const int numberOfSteps = 64;
// Step matrix
int stepMatrix[8][4] = {
{ LOW LOW LOW HIGH }
{ LOW LOW HIGH HIGH }
{ LOW LOW HIGH LOW }
{ LOW HIGH HIGH LOW }
{ LOW HIGH LOW LOW }
{ HIGH HIGH LOW LOW }
{ HIGH LOW LOW LOW }
{ HIGH LOW LOW HIGH }
};
// Output levels to stop the motor
int allLows[4] = { LOW LOW LOW LOW };
/*
* Constructor for four-pin version
* Sets which wires should control the motor.
*/
Stepper2::Stepper2(int motorPin[4])
{
this->step_number = 0; // which step the motor is on
this->last_step_time = 0; // time stamp in us of the last step taken
// setup the pins on the microcontroller:
for (int i = 0; i < 4; i++) {
this->pin_matrix[i] = motorPin[i];
pinMode(motorPin[i] OUTPUT);
}
}
/*
* Sets the speed in revs per minute
*/
void Stepper2::setSpeed(int rpm)
{
int duration = microsInMinute / stepsPerFullTurn / rpm;
int minDuration = microsInSecond / maxHz;
this->step_duration = duration > minDuration ? duration : minDuration;
}
/*
* Sets the speed in revs per minute
*/
void Stepper2::setDirection(int direction)
{
this->direction = direction;
}
/*
* Write pin state to output
*/
void Stepper2::writeStep(int outArray[4]){
for (int i = 0; i < 4; i++) {
digitalWrite(this->pin_matrix[i] outArray[i]);
}
}
/*
* Moves the motor stepsToMove steps.
*/
void Stepper2::step(int stepsToMove)
{
int stepsLeft = abs(stepsToMove); // how many steps to take
// Adjust stepsToMove accrodign to direction
if (this->direction == 1) {
stepsToMove = -stepsToMove;
}
// decrement the number of steps moving one step each time
while (stepsLeft > 0) {
unsigned long now = micros();
// move only if the appropriate delay has passed
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-03-06 19:42 Stepper2-master\
文件 966 2017-03-06 19:42 Stepper2-master\README.adoc
目录 0 2017-03-06 19:42 Stepper2-master\examples\
目录 0 2017-03-06 19:42 Stepper2-master\examples\Stepper2_oneTurn\
文件 561 2017-03-06 19:42 Stepper2-master\examples\Stepper2_oneTurn\stepper_oneRevolution.ino
文件 664 2017-03-06 19:42 Stepper2-master\keywords.txt
文件 310 2017-03-06 19:42 Stepper2-master\library.properties
目录 0 2017-03-06 19:42 Stepper2-master\src\
文件 4364 2017-03-06 19:42 Stepper2-master\src\Stepper2.cpp
文件 1995 2017-03-06 19:42 Stepper2-master\src\Stepper2.h
- 上一篇:数据结构课程设计——地铁建设问题
- 下一篇:STM32多路数据采集源代码
相关资源
- esp8266 win10驱动 cp2102
- ESP32蓝牙架构官方
- CSDN文件---ESP8266.rar
- stm32103c8t6ESP8266串口转WIFI模块TCP服务器
- ESP8266ESP8266安卓控制端源代码
- nudemcu相关工具和固件测试稳定
- 单片机通过ESP8266上传温湿度数据
- STM32F407ZG_ESP8266例程
- ESP8266最新稳定版固件
- ESP8266AP模式控制51单片机亮灯.docx
- ESP8266使用MQTT协议连接阿里云
- 贝壳物联arduino esp8266 demo版本
- ESP8266程序加上MQTT调试工具
- ESP8266_NONOS_SDK-3.0
- ESP8266+OLED屏实现天气预报+温度显示
- stm32f7的esp8266spi并口源程序,速率1.
- ESP8266连接云平台
- STM32C8T6通过扫描二维码进行智能开锁
- ESP8266微信配网以及公众号绑定
- 28BYJ-48步进电机(STM32F1)
- ESP8266一键烧写工具
- 手机与ESP8266WiFi模块进行通信
- ESP8266搭建MQTT客户端源码
- esp32 官方API编程手册
- STM32接入OneNET代码
- STM32-ESP8266-AT
- 毕设-基于ESP8266-12F家电控制系统设计
- 使用MSP432-ESP8266实现小车红外测距和数
- ESP8266_8285_32系列透传固件 JFirmwareESP
- ESP32、ESP8266/85增强型透传固件 JFirmw
评论
共有 条评论