Devices & Components
Arduino Uno Rev3
SG90 Micro-servo motor
Analog joystick (Generic)
5V 1A Power Supply
Jumper wires (generic)
USB-A to B Cable
Software & Tools
Arduino IDE
Project description
Code
servo.ino
arduino
1 2#include <Servo.h> 3 4Servo piana; 5Servo padella; 6int pot1 = A0; 7int pot2 = A1; 8int val1 = 0; 9int val2 = 0; 10 11void setup() { 12 piana.attach(9); 13 padella.attach(10); 14 pinMode (pot1, INPUT); 15 pinMode (pot2, INPUT); 16 Serial.begin(9600); 17} 18 19void loop() { 20 val1 = analogRead(pot1); 21 if (val1 <= 513) { 22 val1 = map(val1, 0, 1023, 70, 110); 23 } 24 else { 25 val1 = map(val1, 0, 1023, 60, 120); 26 } 27 piana.write(val1); 28 val2 = analogRead(pot2); 29 val2 = map(val2, 0, 1023, 75, 105); 30 padella.write(val2); 31 delay(15); 32 33} 34 35 36
servo.ino
arduino
1 2#include <Servo.h> 3 4Servo piana; 5Servo padella; 6int pot1 = A0; 7int pot2 = A1; 8int val1 = 0; 9int val2 = 0; 10 11void setup() { 12 piana.attach(9); 13 padella.attach(10); 14 pinMode (pot1, INPUT); 15 pinMode (pot2, INPUT); 16 Serial.begin(9600); 17} 18 19void loop() { 20 val1 = analogRead(pot1); 21 if (val1 <= 513) { 22 val1 = map(val1, 0, 1023, 70, 110); 23 } 24 else { 25 val1 = map(val1, 0, 1023, 60, 120); 26 } 27 piana.write(val1); 28 val2 = analogRead(pot2); 29 val2 = map(val2, 0, 1023, 75, 105); 30 padella.write(val2); 31 delay(15); 32 33} 34 35 36
Downloadable files
Electrical Connections
The following image shows the electrical connections, the joystick is replaced with two potentiometers since it is not present in the software.
Electrical Connections

Comments
Only logged in users can leave comments