Jittering servos

Also they have no jittering problem when I use servo.h library and no libraries using the same timer with it.

The Sg90 or the Mg995?

Aside from this I have never been able to create the perfect connection for potentiometers. I bought 10 brand new pots and soldered them cleanly (3 of them/amount I need) however they still sometimes send odd values. Do you have any idea why?

I use sg90 now but I plan to use mg995 in the final product.

Which servo doesn't jitter? Both MG995 and SG90 or just SG90 or just Mg995?

I do not have mg995 now (it was not jittering when I had in the past) but sg90 (probably any other servo) does not jitter when I don't use SoftwareSerial library (i think they use the same timer/when I use servo.h lib).

Are there anything which is not clear?

I know for sure that you need to upgrade your servo power supply. Do that and see if your servos still jitter.

The phone charger will only output so much amperage. The max I've seen is 5v 2.1A, which is enough to power only 1 SG90 servo.

(Don't worry, you're not going to burn out your servo if you give it access to plenty of amperage. The servo will only take what it needs. The problems happen when you try powering several servos with limited/not enough amperage).

Also, I'm not too familiar with the HC12 module, but I did find this:

This should help you out. I noticed that they used Millis as their delay timer instead of the delay function in their code.

If you're worried about the timer, try using Millis.

If you don't know what Millis is or how to use it this should help.

(This is a chunk of code from an A.I project of mine. Millis allows my A.I to multitask. The delay stops everything in it's track, but Millis just pauses the thing it's controlling, and let's the other stuff run in the background; It's non-blocking).

//Millis-Link: https://www.norwegiancreations.com/2017/09/arduino-tutorial-using-millis-instead-of-delay/
int period1 = 1000; //1sec Delay
int period2 = 2000; //2sec Delay
int period3 = 3000; //3sec Delay
int period4 = 4000; //4sec Delay
unsigned long time_now = 0;

This should give you a general idea of how Millis works if you're interested in using it.

 //Command 23
    if (res == 23) {
    randNumber = random(1,6); //Pick a number from 1-6
    recognizer.say("It rolled on"+String(randNumber)); //Say the chosen number 
    RGB_color(255, 255, 255); //White
   //Display the random number on OLED then turn off after 4 sec
   time_now=millis(); 
   //Everything that I want displayed/running for 4 sec goes here:
  //--You can put your servo.write commands here.
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,17);
   display.print("    "+String(randNumber)); 
   display.display();  
   //And ends here. Now I must say how long I want it to be displayed:
   while(millis()<time_now+period4){ //Time_now (0sec)+period4 (4sec)=4sec delay)
   //wait approx 4sec. Hence I use period4 which I defined as 4 seconds. 
   }
  //After 4 sec clear my OLED and call the Splash Screen and turn off my RGB LED.
 //--Now you can put your servo return commands or leave it blank so nothing happens after the delay. 
  RGB_color(0, 0, 0); //Turns off after 4 sec
  SplashScreen(); //Calls Splash Screen Subroutine after 4 sec
  }

This should be more tailored to your needs.

   {
     time_now=millis(); 
   //Everything that you want displayed/running for 4 sec goes here:
    servo.write(90);
   //And ends here. 
   //Now you must say how long you want it to be displayed:
   while(millis()<time_now+period4){ 
   //wait approx 4sec. Hence I use period4 which I defined as 4 seconds. 
   }
 //--Now you can put your servo return commands or leave it blank so nothing happens after the delay. 
  servo.write(0);
  }

Hope this help.

The MG995 servo has a start/stall current of 1.2 Amperes. The servo power supply MUST be able to supply more than that, per servo, so more than 6 Amperes for 5 servos. I would choose 10 A to be on the safe side.

If this is for a commercial product, you certainly have a learning curve ahead of you.

It is not a comercial product. A personal project for 9th grade.

Hi, I could not do it with millis so I started to search for another library for servos. Happily I could find one that works perfectly even with softwareserial.h library without jittering. Unfortuneatly this library only lets us to use pin 9. Do you think is there a way to edit the library to make it possible to use other pins?
The library: PWMServo - Arduino Libraries
Another library: PWMServo | Arduiniana

Specific PWM pins are associated with specific timers on the Uno (pins 3&9 with Timer1), so if the library uses Timer1, you can't change those pins without changing timers.

There are servo control modules that communicate using I2C or SPI or TTL serial and don't suffer from those limitations. Here is one example and another.

Servo.h uses timer interrupts for timing the servo pulses. SoftwareSerial.h turns off interrupts while it sends each character. 9600-baud takes about a millisecond (the length of the longest servo pulse) to send a character. That causes jitter. A much higher baud rate (115200?) will help some. Using a processor with a spare hardware serial port (like Leonardo or MEGA) would eliminate the need for SoftwareSerial.

Your examples with millis() are blocking everything exactly the same way as delay() would do. Just saying.

I thank all of you. Instead of using software serial I decided to use NeoSWSerial.h and this solved the timer issue. The project is going fine now and I hope it continues like this. Again thank you all for helping.