0% found this document useful (0 votes)
44 views2 pages

CODEEasyArmDS2 1

Uploaded by

davifigbr22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views2 pages

CODEEasyArmDS2 1

Uploaded by

davifigbr22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

// _ ___ _______ ___ ___ ___ ___ _ _ ___ _____ ___

// / |_ )__ / \ / __|_ _| _ \/ __| | | |_ _|_ _/ __|


// | |/ / |_ \ |) | | (__ | || / (__| |_| || | | | \__ \
// |_/___|___/___/ \___|___|_|_\\___|\___/|___| |_| |___/
//
// CODE EasyArmDS2
//
// Made by Mauriciodgsantos Mauriciodgsantos
// License: CC-BY-SA 3.0
// Downloaded from: https://circuits.io/circuits/2690706-code-easyarmds2

/*
Controle do Braço Robótico EasyArmDS2 através de
cinco potenciometros by MauricioDuarte

Controlling a servo position using a potentiometer (variable resistor)


by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

modified on 8 Nov 2013


by Scott Fitzgerald
http://arduino.cc/en/Tutorial/Knob
*/

#include <Servo.h>

Servo myservo_pulso;
Servo myservo_garra;
Servo myservo_antebraco;
Servo myservo_base;
Servo myservo_braco;

int potpin = 0;
int potpin1 = 1;
int potpin2 = 2;
int potpin3 = 3;
int potpin4 = 4;

// pinos analógicos conectados aos potenciometros


int val; // variavel de leitura dos pinos analógicos

void setup()
{
myservo_pulso.attach(9);
myservo_garra.attach(10);
myservo_antebraco.attach(6);
myservo_base.attach(5);
myservo_braco.attach(11);
// attaches dos servos aos pinos correspondentes
}

void loop()
{
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 180);
myservo_pulso.write(val);
delay(15);
val = analogRead(potpin1);
val = map(val, 0, 1023, 40, 120);
myservo_garra.write(val);
delay(15);

val = analogRead(potpin2);
val = map(val, 0, 1023, 0, 180);
myservo_antebraco.write(val);
delay(15);

val = analogRead(potpin4);
val = map(val, 0, 1023, 0, 180);
myservo_braco.write(val);
delay(15);

val = analogRead(potpin3);
val = map(val, 0, 1023, 0, 180);
myservo_base.write(val);
delay(15);
}

You might also like