Go Down

Topic: New to coding, can someone look over this? (Read 534 times) previous topic - next topic

zspritz

Most of this is not my own but i made some changes. This is for controlling servos with potentiometers to be used in master slave control.


#include <Servo.h>

Servo myservo3;

Servo myservo5;

Servo myservo6;

Servo myservo7;

Servo myservo8;

Servo myservo9;


int potpin = 0;
int potpin2 = 1;

int potpin3 = 2;

int potpin4 = 3;

int potpin5 = 4;

int potpin6 = 5;

int val = 0;
int val2 = 0;

int val3 = 0;

int val4 = 0;

int val5 = 0;

int val6 = 0;

void setup()
{

myservo3.attach(9);
myservo5.attach(10);

myservo6.attach(11);

myservo7.attach(12);

myservo8.attach(13);

myservo9.attach(14);

}

void loop()
{

val = analogRead(potpin);
val = map(val, 3, 1023, 0, 176);

myservo3.write(val);

delay(25);

val2 = analogRead(potpin2);
val2 = map(val2, 3, 1023, 0, 176);

myservo5.write(val2);

delay(25);

val3 = analogRead(potpin3);
val3 = map(val3, 3, 1023, 0, 175);

myservo6.write(val3);

delay(25);

val4 = analogRead(potpin4);
val4 = map (val4, 3, 1023, 0, 175)

myservo7.write(val4)

delay(25);

val5 = analogRead(potpin5);
val5 = map (val5, 3, 1023, 0, 175)

myservo8.write(val5)

delay(25);


val6 = analogRead(potpin6);
val6 = map (val6, 3, 1023, 0, 175)

myservo9.write(val6)

delay(25);

}

MarkT

Please stop cross-posting - I make it 4 identical threads now.  Are you determined to waste peoples' time?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up