SlideShare a Scribd company logo
1 of 2
#include <Servo.h> 
const int servo1 = 3; // first servo 
const int servo2 = 10; // second servo 
const int servo3 = 5; // third servo 
const int servo4 = 11; // fourth servo 
const int servo5 = 9; // fifth servo 
const int joyH = 2; // L/R Parallax Thumbstick 
const int joyV = 3; // U/D Parallax Thumbstick 
const int joyX = 4; // L/R Parallax Thumbstick 
const int joyP = 5; // U/D Parallax Thumbstick 
const int potpin = 0; // O/C potentiometer 
int servoVal; // variable to read the value from the analog pin 
Servo myservo1; // create servo object to control a servo 
Servo myservo2; // create servo object to control a servo 
Servo myservo3; // create servo object to control a servo 
Servo myservo4; // create servo object to control a servo 
Servo myservo5; // create servo object to control a servo 
void setup() { 
// Servo 
myservo1.attach(servo1); // attaches the servo 
myservo2.attach(servo2); // attaches the servo 
myservo3.attach(servo3); // attaches the servo 
myservo4.attach(servo4); // attaches the servo 
myservo5.attach(servo5); // attaches the servo 
// Inizialize Serial 
Serial.begin(9600); 
} 
void loop(){ 
servoVal = analogRead(potpin); 
servoVal = map(servoVal, 0, 1023, 0, 179); 
myservo5.write(servoVal); 
delay(15); 
// Display Joystick values using the serial monitor 
outputJoystick(); 
// Read the horizontal joystick value (value between 0 and 1023) 
servoVal = analogRead(joyH); 
servoVal = map(servoVal, 0, 1023, 0, 180); // scale it to use it with 
the servo (result between 0 and 180) 
myservo2.write(servoVal); // sets the servo position 
according to the scaled value 
// Read the horizontal joystick value (value between 0 and 1023) 
servoVal = analogRead(joyV); 
servoVal = map(servoVal, 0, 1023, 70, 180); // scale it to use it with 
the servo (result between 70 and 180) 
myservo1.write(servoVal); // sets the servo 
position according to the scaled value 
delay(15); // waits for the servo to
get there 
// Read the horizontal joystick value (value between 0 and 1023) 
servoVal = analogRead(joyP); 
servoVal = map(servoVal, 0, 1023, 70, 180); // scale it to use it with 
the servo (result between 70 and 180) 
myservo4.write(servoVal); // sets the servo 
position according to the scaled value 
delay(15); // waits for the servo to 
get there 
// Read the horizontal joystick value (value between 0 and 1023) 
servoVal = analogRead(joyX); 
servoVal = map(servoVal, 0, 1023, 70, 180); // scale it to use it with 
the servo (result between 70 and 180) 
myservo3.write(servoVal); // sets the servo 
position according to the scaled value 
delay(15); // waits for the servo to 
get there 
} 
/** 
* Display joystick values 
*/ 
void outputJoystick(){ 
Serial.print(analogRead(joyH)); 
Serial.print ("---"); 
Serial.print(analogRead(joyV)); 
Serial.println ("----------------"); 
Serial.print(analogRead(joyP)); 
Serial.println ("----------------"); 
Serial.print(analogRead(joyX)); 
Serial.println ("----------------"); 
}

More Related Content

What's hot

What's hot (17)

week-4x
week-4xweek-4x
week-4x
 
Rcpp11 genentech
Rcpp11 genentechRcpp11 genentech
Rcpp11 genentech
 
week-18x
week-18xweek-18x
week-18x
 
みんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swiftみんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swift
 
week-10x
week-10xweek-10x
week-10x
 
week-1x
week-1xweek-1x
week-1x
 
Advanced Patterns with io.ReadWriter
Advanced Patterns with io.ReadWriterAdvanced Patterns with io.ReadWriter
Advanced Patterns with io.ReadWriter
 
Two-StageCreation
Two-StageCreationTwo-StageCreation
Two-StageCreation
 
Loop control structure
Loop control structureLoop control structure
Loop control structure
 
Unit 1 of c++ first program
Unit 1 of c++ first programUnit 1 of c++ first program
Unit 1 of c++ first program
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 
Andrii Orlov "Generators Flexibility in Modern Code"
Andrii Orlov "Generators Flexibility in Modern Code"Andrii Orlov "Generators Flexibility in Modern Code"
Andrii Orlov "Generators Flexibility in Modern Code"
 
First c program
First c programFirst c program
First c program
 
Stack application
Stack applicationStack application
Stack application
 
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollideropenFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
 
Computer programing w
Computer programing wComputer programing w
Computer programing w
 
week-16x
week-16xweek-16x
week-16x
 

Viewers also liked

Drv8833 motor driver datasheet
Drv8833 motor driver datasheetDrv8833 motor driver datasheet
Drv8833 motor driver datasheetMahmut Yildiz
 
Micro sd specification
Micro sd specificationMicro sd specification
Micro sd specificationMahmut Yildiz
 
Introduction to modulation and demodulation
Introduction to modulation and demodulationIntroduction to modulation and demodulation
Introduction to modulation and demodulationMahmut Yildiz
 

Viewers also liked (6)

Matlabders
MatlabdersMatlabders
Matlabders
 
Drv8833 motor driver datasheet
Drv8833 motor driver datasheetDrv8833 motor driver datasheet
Drv8833 motor driver datasheet
 
Lecture7
Lecture7Lecture7
Lecture7
 
Micro sd specification
Micro sd specificationMicro sd specification
Micro sd specification
 
Matlab.pdf
Matlab.pdfMatlab.pdf
Matlab.pdf
 
Introduction to modulation and demodulation
Introduction to modulation and demodulationIntroduction to modulation and demodulation
Introduction to modulation and demodulation
 

Similar to Control 5 Servos with Joystick and Potentiometer

Arduinomotorcontrolusingservoultrasonic
ArduinomotorcontrolusingservoultrasonicArduinomotorcontrolusingservoultrasonic
ArduinomotorcontrolusingservoultrasonicNaveenBasireddy
 
DomCode 2015 - Abusing phones to make the internet of things
DomCode 2015 - Abusing phones to make the internet of thingsDomCode 2015 - Abusing phones to make the internet of things
DomCode 2015 - Abusing phones to make the internet of thingsJan Jongboom
 
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdfalltiusind
 
Promises, promises, and then observables
Promises, promises, and then observablesPromises, promises, and then observables
Promises, promises, and then observablesStefan Charsley
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxamrit47
 
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4Kaku Tomohiro
 
响应式编程及框架
响应式编程及框架响应式编程及框架
响应式编程及框架jeffz
 
SENDER It is a helmet that contains a sensor for gases, vital s.pdf
SENDER  It is a helmet that contains a sensor for gases, vital s.pdfSENDER  It is a helmet that contains a sensor for gases, vital s.pdf
SENDER It is a helmet that contains a sensor for gases, vital s.pdfalertshoeshingkimand
 
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdfC++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdfandreaplotner1
 
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdfpublic void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdfisenbergwarne4100
 
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docxkatherncarlyle
 
Header files used to run the program include ltstdioh.pdf
Header files used to run the program  include ltstdioh.pdfHeader files used to run the program  include ltstdioh.pdf
Header files used to run the program include ltstdioh.pdficonsystemsslm
 

Similar to Control 5 Servos with Joystick and Potentiometer (20)

Metal detecting robot sketch
Metal detecting robot sketchMetal detecting robot sketch
Metal detecting robot sketch
 
Arduinomotorcontrolusingservoultrasonic
ArduinomotorcontrolusingservoultrasonicArduinomotorcontrolusingservoultrasonic
Arduinomotorcontrolusingservoultrasonic
 
StewartPlatform_cpp
StewartPlatform_cppStewartPlatform_cpp
StewartPlatform_cpp
 
DomCode 2015 - Abusing phones to make the internet of things
DomCode 2015 - Abusing phones to make the internet of thingsDomCode 2015 - Abusing phones to make the internet of things
DomCode 2015 - Abusing phones to make the internet of things
 
Open bot
Open bot Open bot
Open bot
 
OpenBot-Code
OpenBot-CodeOpenBot-Code
OpenBot-Code
 
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 
Promises, promises, and then observables
Promises, promises, and then observablesPromises, promises, and then observables
Promises, promises, and then observables
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
 
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
 
响应式编程及框架
响应式编程及框架响应式编程及框架
响应式编程及框架
 
SENDER It is a helmet that contains a sensor for gases, vital s.pdf
SENDER  It is a helmet that contains a sensor for gases, vital s.pdfSENDER  It is a helmet that contains a sensor for gases, vital s.pdf
SENDER It is a helmet that contains a sensor for gases, vital s.pdf
 
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdfC++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
 
4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf
 
app.js.docx
app.js.docxapp.js.docx
app.js.docx
 
Edge_AI_Assignment_3.pdf
Edge_AI_Assignment_3.pdfEdge_AI_Assignment_3.pdf
Edge_AI_Assignment_3.pdf
 
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdfpublic void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
 
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
 
Header files used to run the program include ltstdioh.pdf
Header files used to run the program  include ltstdioh.pdfHeader files used to run the program  include ltstdioh.pdf
Header files used to run the program include ltstdioh.pdf
 
Verilog_Examples (1).pdf
Verilog_Examples (1).pdfVerilog_Examples (1).pdf
Verilog_Examples (1).pdf
 

More from Mahmut Yildiz

More from Mahmut Yildiz (10)

Tcs230
Tcs230Tcs230
Tcs230
 
Microsd card spec
Microsd card specMicrosd card spec
Microsd card spec
 
Lecture6
Lecture6Lecture6
Lecture6
 
Comunication project
Comunication projectComunication project
Comunication project
 
Audioprocessing
AudioprocessingAudioprocessing
Audioprocessing
 
Us6330335
Us6330335Us6330335
Us6330335
 
96683234 project-report-steganography
96683234 project-report-steganography96683234 project-report-steganography
96683234 project-report-steganography
 
Amplitude modulation
Amplitude modulationAmplitude modulation
Amplitude modulation
 
Matlab grafik
Matlab grafikMatlab grafik
Matlab grafik
 
Basic Info for Matlab
 Basic Info for Matlab Basic Info for Matlab
Basic Info for Matlab
 

Recently uploaded

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 

Recently uploaded (20)

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 

Control 5 Servos with Joystick and Potentiometer

  • 1. #include <Servo.h> const int servo1 = 3; // first servo const int servo2 = 10; // second servo const int servo3 = 5; // third servo const int servo4 = 11; // fourth servo const int servo5 = 9; // fifth servo const int joyH = 2; // L/R Parallax Thumbstick const int joyV = 3; // U/D Parallax Thumbstick const int joyX = 4; // L/R Parallax Thumbstick const int joyP = 5; // U/D Parallax Thumbstick const int potpin = 0; // O/C potentiometer int servoVal; // variable to read the value from the analog pin Servo myservo1; // create servo object to control a servo Servo myservo2; // create servo object to control a servo Servo myservo3; // create servo object to control a servo Servo myservo4; // create servo object to control a servo Servo myservo5; // create servo object to control a servo void setup() { // Servo myservo1.attach(servo1); // attaches the servo myservo2.attach(servo2); // attaches the servo myservo3.attach(servo3); // attaches the servo myservo4.attach(servo4); // attaches the servo myservo5.attach(servo5); // attaches the servo // Inizialize Serial Serial.begin(9600); } void loop(){ servoVal = analogRead(potpin); servoVal = map(servoVal, 0, 1023, 0, 179); myservo5.write(servoVal); delay(15); // Display Joystick values using the serial monitor outputJoystick(); // Read the horizontal joystick value (value between 0 and 1023) servoVal = analogRead(joyH); servoVal = map(servoVal, 0, 1023, 0, 180); // scale it to use it with the servo (result between 0 and 180) myservo2.write(servoVal); // sets the servo position according to the scaled value // Read the horizontal joystick value (value between 0 and 1023) servoVal = analogRead(joyV); servoVal = map(servoVal, 0, 1023, 70, 180); // scale it to use it with the servo (result between 70 and 180) myservo1.write(servoVal); // sets the servo position according to the scaled value delay(15); // waits for the servo to
  • 2. get there // Read the horizontal joystick value (value between 0 and 1023) servoVal = analogRead(joyP); servoVal = map(servoVal, 0, 1023, 70, 180); // scale it to use it with the servo (result between 70 and 180) myservo4.write(servoVal); // sets the servo position according to the scaled value delay(15); // waits for the servo to get there // Read the horizontal joystick value (value between 0 and 1023) servoVal = analogRead(joyX); servoVal = map(servoVal, 0, 1023, 70, 180); // scale it to use it with the servo (result between 70 and 180) myservo3.write(servoVal); // sets the servo position according to the scaled value delay(15); // waits for the servo to get there } /** * Display joystick values */ void outputJoystick(){ Serial.print(analogRead(joyH)); Serial.print ("---"); Serial.print(analogRead(joyV)); Serial.println ("----------------"); Serial.print(analogRead(joyP)); Serial.println ("----------------"); Serial.print(analogRead(joyX)); Serial.println ("----------------"); }