Stepper Motor
It is used to precisely control the rotation. The Stepper motor can rotate 360 degrees.
Sketch :
int Pin0 = 8;
int Pin1 = 9;
int Pin2 = 10;
int Pin3 = 11;
int _step = 512;
int _speed = 1;
void setup()
{
pinMode(Pin0, OUTPUT);
pinMode(Pin1, OUTPUT);
pinMode(Pin2, OUTPUT);
pinMode(Pin3, OUTPUT);
}
void loop()
{
Speed(15);
Step(512);
delay(2000);
Speed(15);
Step(-512);
delay(2000);
}
void Speed(int stepperspeed)
{
_speed = 15 - stepperspeed;
if( _speed<1 _speed="" if="">15){
_speed = 15;
}
}
void Step(int _step)
{
if(_step>=0){
for(int i=0;i<_step 0="" 1="" a="" b="" c="" code="" d="" delay="" digitalwrite="" else="" for="" i="_step;i<0;i++){" in0="" in1="" in2="" in3="" int="" setstep="" speed="" void="">
1>
Thank you!
No comments:
Post a Comment
សូមអរគុណ!