Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <VarSpeedServo.h>
- VarSpeedServo servo_base;
- VarSpeedServo servo_inclinacao;
- int pino_x = A4; //Pino ligado ao X do joystick
- int val_x; //Armazena o valor do eixo X
- int ServoX = 0;
- //----------------------------
- void setup()
- {
- Serial.begin(9600);
- servo_base.attach(7, 1, 180);
- }
- //----------------------------
- void loop()
- {
- val_x = analogRead(pino_x);
- Serial.print("val_x "); Serial.println(val_x);
- if (val_x > 750)
- {
- ServoX ++;
- if (ServoX >= 180 ) ServoX = 180;
- }
- if (val_x < 300)
- {
- ServoX --;
- if (ServoX <= 0 ) ServoX = 0;
- }
- Serial.print("ServoX "); Serial.println(ServoX);
- servo_base.slowmove(ServoX, 60);
- delay(30);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement