“Robot “Arm”"

This script operates 2 stepper motors using 2 potentiometers.  playing with the values allows you to calibrate the sensitivity of the motors.

#include <Stepper.h>

#define STEPS 100 // no. of steps on motor

Stepper stepper(STEPS, 8, 9, 10, 11); // stepper, number of steps, pins

Stepper stepper1(STEPS, 4, 5, 6, 7);

int potval0 = 0; //incoming potentiometer values

int potval1 = 1;

int previous = 0;

int previous1 = 0;

int potmin = 1023;// pot minimum and maximum for re-mapping the values

int potmax = 0;

void setup()

{

// set the speed of the motor (RPMs)

stepper.setSpeed(50);

stepper1.setSpeed(50);

}

void loop()

{

// get the sensor value

potval0 = analogRead(0);

potval0 = map(potval0, potmin, potmax, 0, 100);//re-map sensor value to no. of steps

potval1 = analogRead(1);

potval1 = map(potval1, potmin, potmax, 0, 100);

int val = potval0;

int val1 = potval1;

stepper.step(val – previous); //number of steps sent to sensor

stepper1.step(val1 – previous1); // remember the previous value of the sensor

previous = val;

previous1 = val1;

}

This entry was posted in RS3. Digital Tectonics and tagged . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*


− two = 3


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>