Needle swip GOLF 4

Hi
I have just a quick question
I made this in my car and it work
I want to know how I can get the arrow to go up to 260Km and down to 0 again
it has to move only once. my going up and down all the time :frowning:

the stepper motor is the 4-wire

With no details of the hardware, how it is connected to the Arduino or the program that you are running I suspect that nobody will be able to provide any help. The video is certainly no help.

this is the code

and I use

arduino r3 uno

/*

  • MotorKnob
  • A stepper motor follows the turns of a potentiometer
  • (or other sensor) on analog input 0.
  • Stepper - Arduino Reference
  • This example code is in the public domain.
    */

#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;
}

If you want to do something once, you do it in setup(). If you want to do something over and over, you do it in loop().

If you do something in loop(), you should not be surprised that it happens over and over.

Could you maybe edit the topic title please?

I have no idea what it means.

Look here:
https://www.google.com/search?ie=UTF-8&oe=UTF-8&q=gauge+stepper&btnG=search&domains=http%3A%2F%2Fforum.arduino.cc&sitesearch=http%3A%2F%2Fforum.arduino.cc&gws_rd=ssl

PAULS
so its will be correct like this?

/*

  • MotorKnob
  • A stepper motor follows the turns of a potentiometer
  • (or other sensor) on analog input 0.
  • Stepper - Arduino Reference
  • This example code is in the public domain.
    */

#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);
}

so its will be correct like this?

No.

:frowning:
Can you send me the code pls?

kangal:
:frowning:
Can you send me the code pls?

To do what?

The code you posted the first time did what you said you wanted, except that it did it over and over.

You need to understand the part of the code that moves the stepper motor. You need to move that to setup() if you don't want it to happen over and over.

DONT WORK :(((

/*
Stepper Motor Control - one revolution

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.

The motor should revolve one revolution in one direction, then
one revolution in the other direction.

Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe

*/

#include <Stepper.h>

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}

void loop() {
// step one revolution in one direction:

}

so successful
thank you very much :slight_smile: