欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2591|回復: 4
收起左側

arduino步進電機程序

[復制鏈接]
ID:28942 發表于 2018-7-7 11:07 | 顯示全部樓層 |閱讀模式
論壇很少有arduino的仿真,對不想買板子的壇友真沒法驗證代碼正確與否,在這里貼個仿真供參考。
ATMEGA328最小系統
程序代碼


#include <Stepper.h>

/*-----( Declare Constants, Pin Numbers)-----*/
//---( Number of steps per revolution ofINTERNAL motor in 4-step mode )---
#define STEPS_PER_MOTOR_REVOLUTION 32   

//---( Steps per OUTPUT SHAFT of gearreduction )---
#define STEPS_PER_OUTPUT_REVOLUTION 32 *64  //2048  


/*-----( Declare objects )-----*/
// create an instance of the stepper class,specifying
// the number of steps of the motor and thepins it's
// attached to
//-------------------------------------------------------------
//The pin connections need to be pins8,9,10,11 connected
// to Motor Driver In1, In2, In3, In4
//-------------------------------------------------------------

// Then the pins are entered here in thesequence 1-3-2-4 for proper sequencing
Steppersmall_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);

/*-----( Declare Variables )-----*/
int Steps2Take;

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
// Nothing (Stepper Library sets pins as outputs)
}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
Steps2Take  =  STEPS_PER_OUTPUT_REVOLUTION ;  // Rotate CW 1 turn
small_stepper.setSpeed(500);   
small_stepper.step(Steps2Take);
delay(1000);

Steps2Take  =  - STEPS_PER_OUTPUT_REVOLUTION;  // Rotate CCW 1 turn  
small_stepper.setSpeed(500);  //700 a good max speed??
small_stepper.step(Steps2Take);
delay(2000);
}





回復

使用道具 舉報

ID:1 發表于 2018-7-8 03:16 | 顯示全部樓層
缺少仿真
回復

使用道具 舉報

ID:28942 發表于 2018-7-8 07:57 | 顯示全部樓層

您好,我又重發了一遍,
回復

使用道具 舉報

ID:1 發表于 2018-7-8 17:48 | 顯示全部樓層
附件還是沒加上呢 你看教程:http://m.raoushi.com/bbs/dpj-49501-1.html
回復

使用道具 舉報

ID:28942 發表于 2018-7-9 10:14 | 顯示全部樓層
抱歉,上次沒發成功,
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表