ENGLISH
Hi, I'm trying to move a servo motor with an analog like that of a PS4 controller, it goes perfectly just for a problem ... When I release the analog, the movement is calculated then once the analogue is released the servomotor goes to the position initial.
Do you know how to solve?
If I have not been clear, write to me that I'll do it again!
Thanks in advance for the answer ...!
Here is the sketch I use !:
#include <Servo.h>
Servant servant1;
int const potPinX = A1;
int potVal;
int angle;
void setup () {
servo1.attach (9);
Serial.begin (9600);
}
void loop () {
potVal = analogRead (potPinX);
Serial.print ("potVal:");
Serial.print (potVal);
angle = map (potVal, 0, 1023, 0, 179);
Serial.print ("angle:");
Serial.println (angle);
servo1.write (angle);
delay (15);
}
**** The Joystick is this **** = https://www.ebay.it/itm/2x-JoyStick-Breakout-Module-Shield-PS2-Game-Switches-Controller-for-Arduino/283312054526?ssPageName = STRK% 3AMEBIDX% 3AIT & _trksid = p2057872.m2749.l2649
**** The engines are these ****: https://www.ebay.it/itm/MG90S-Servo-motore-RC-auto-servocomando-robotica-arduino-mini-modellismo-kit/123367743478?ssPageName = STRK% 3AMEBIDX% 3AIT & var = 423762598811 & _trksid = p2057872.m2749.l2649
**** Usage: Arduino UNO ****
ITALIANO
Salve, sto cercando di far muovere un servomotore con un analogico tipo quello di un controller PS4, va perfettamente solo per un problema... Quando rilascio l'analogico, il movimento viene calcolato quindi una volta rilasciato l'analogico il servomotore va alla posizione iniziale.
Sapete come risolvere?
Se nn sono stato chiaro scrivetemelo che vi rispiego!
Grazie in anticipo per la risposta...!
Ecco lo sketch che uso!:
#include <Servo.h>
Servo servo1;
int const potPinX = A1;
int potVal;
int angle;
void setup() {
servo1.attach(9);
Serial.begin(9600);
}
void loop() {
potVal = analogRead(potPinX);
Serial.print("potVal: ");
Serial.print(potVal);
angle = map(potVal, 0, 1023, 0, 179);
Serial.print("angle: ");
Serial.println(angle);
servo1.write(angle);
delay(15);