Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
Modulo Joystick
SG90 Micro-servo motor
Hardware & Tools
Multitool, Screwdriver
Software & Tools
Arduino IDE
Project description
Code
Joystick control servo code
html
Code for the all parts of this project.
1#include <Servo.h> 2 3//Include the servo library 4 5Servo servo1; 6Servo servo2; 7 8int joyX =0; 9int joyY =1; 10 11 12int joyVal; 13 14void setup() 15{ //attaches our servos on pins PWM 3-5 16 servo1.attach(3); 17 servo2.attach(5); 18} 19 20void loop() 21{ 22 //read the value of joystick (between 0-1023) 23 joyVal = analogRead(joyX); 24 joyVal = map (joyVal, 0, 1023, 0, 180); //servo value between 0-180 25 servo1.write(joyVal); //set the servo position according to the joystick value 26 27 joyVal = analogRead(joyY); 28 joyVal = map (joyVal, 0, 1023, 0, 180); 29 servo2.write(joyVal); 30 delay(15); 31}G 32
Downloadable files
Circuit diagram
This is the circuit
Circuit diagram

Circuit diagram
This is the circuit
Circuit diagram

Comments
Only logged in users can leave comments