Hardware components | ||||||
![]() |
| × | 1 | |||
![]() |
| × | 3 | |||
![]() |
| × | 1 | |||
| × | 1 | ||||
![]() |
| × | 14 | |||
The other day I bought a pack of 6 mini servos online and I wanted to make something out of it. Soo SBEEM a mini robotic arm! Enjoy!
I build the structure with cardboard pieces and a block of wood, all tied up with tape and hot glue.
Here's a little demostration of how it works(it's still a little bit wobbly)
//joystick:connect the 5V pin to 5V on the board, the GRD pin to GRD on the board, the X axis to the analogic pin 0, the Y axis to the analogic pin 1 and the SW pin to the analogic pin 3
//servo n.1:connect the red cable to the 5V on the board, the brown/black cable to GRD on the board and the yellow/orange cable to the pin 3
//servo n.2:connect the red cable to the 5V on the board, the brown/black cable to GRD on the board and the yellow/orange cable to pin 5
#include <Servo.h>//include the servo library
Servo servo1;//define the name of the servo n.1
Servo servo2;//define the name of the servo n.2
Servo servo3;//define the name of servo n.3
int X=0;//define which analogic pin the X axis of the joystick is attached to on the board
int Y=1;//define which analogic pin the Y axis of the joystick is attached to on the board
int SW=3;//define which analogic pin the SW is connected to
int ServoVal;//create a value for the servo motors
void setup() {
servo1.attach(3);//define which pin to attach the servo n.1
servo2.attach(5);//define which pin to attach the servo n.2
servo3.attach(7);//define which pin to attach servo n.3
}
void loop() {
ServoVal=analogRead(X);//set the value of the servo as the analogic read of the X axis of the joystick
ServoVal=map(ServoVal, 0, 1023, 0, 180);//map the values for the joystick
servo1.write(ServoVal);//write the value on the servo n.1
ServoVal=analogRead(Y);//set the value of the servo as the analogic read of the Y axis of the joystick
ServoVal=map(ServoVal, 0, 1023, 70, 180);//map the values for the joystick
servo2.write(ServoVal);//write the value on the servo n.2
delay(15);//a bit of delay to avoid rebounce
if(analogRead(SW)==LOW) {
ServoVal=180;
servo3.write(ServoVal);
} if(analogRead(SW)==HIGH) {
ServoVal=0;
servo3.write(ServoVal);
}
}
//doing so you can move the servo motors using X and Y axis of the joystick



_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)







Comments