Pages: 1 [2]   Go Down
Author Topic: tryiing to get a stepper motor to work on ardiuno  (Read 2366 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this is the code im am using:

/*
 * MotorKnob
 *
 * A stepper motor follows the turns of a potentiometer
 * (or other sensor) on analog input 0.
 *
 * http://www.arduino.cc/en/Reference/Stepper
 */

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 100

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);

// the previous reading from the analog input
int previous = 0;

void setup()
{
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(30);
}

void loop()
{
  // get the sensor value
  int val = analogRead(0);

  // move a number of steps equal to the change in the
  // sensor reading
  stepper.step(val - previous);

  // remember the previous value of the sensor
  previous = val;
}



when using this code it will rotate but it rotates even when your not touching the pot and it will randomly change direction on its own.it will sometimes shudder backwards and forwards.If you rotate the pot it may sometimes change direction heading in the opposite direction but if you wind the pot from one end to the other you can hear the motor change the tone as well


thanks for that information cr0sh the motor is opperatinga spring loaded device so when power is lost it should return back to the same position as started but trail and error will prove that fact lol

thanks Joe
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi been tring to have a bit of a play with my arduino and it woat let me down lode to it, it some's up with this:
avrdude: stk500_paged_write() : (a) protocol error, expect=0x14, resp=0x64
avrdude: failed to write flash memory, rc=4
avrdude: stk500_disable () :protocol error, expect=0x14, resp=0x51

any one no what's going on???
thanks Joe
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

help lol
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i guess im at the give up stage now lol
Logged

Pages: 1 [2]   Go Up
Jump to: