Thanks to visit codestin.com
Credit goes to www.scribd.com

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

4 Dof Robotic Arm

This document contains an Arduino sketch that controls four servos using potentiometers. It reads analog values from four potentiometers, maps these values to angles between 0 and 180 degrees, and writes the corresponding angles to the servos. The angles are also printed to the serial monitor for debugging purposes.

Uploaded by

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

4 Dof Robotic Arm

This document contains an Arduino sketch that controls four servos using potentiometers. It reads analog values from four potentiometers, maps these values to angles between 0 and 180 degrees, and writes the corresponding angles to the servos. The angles are also printed to the serial monitor for debugging purposes.

Uploaded by

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

#include <Servo.

h>

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

const int potPin1 = A0;


const int potPin2 = A1;
const int potPin3 = A2;
const int potPin4 = A3;

int potValue1 = 0;
int potValue2 = 0;
int potValue3 = 0;
int potValue4 = 0;

void setup() {
Serial.begin(9600);
servo1.attach(3);
servo2.attach(5);
servo3.attach(6);
servo4.attach(9);

void loop() {
int a = analogRead(A0);
int b = analogRead(A1);
int c = analogRead(A2);
int d = analogRead(A3);

int m = map(a,0,1023,0,180);
int n = map(b,0,1023,0,180);
int o = map(c,0,1023,0,180);
int p = map(d,0,1023,0,180);

servo1.write(m);
servo2.write(n);
servo3.write(o);
servo4.write(p);
Serial.println( "angle1 = ");
Serial.println(m);

Serial.println( "angle2 = ");


Serial.println( n);

Serial.println( "angle3 = ");


Serial.println( o);

Serial.println( "angle4 = ");


Serial.println(p);

// put your main code here, to ;


}

You might also like