Servo mg995 and ttp223

Hi!
I made a project with esp8266, servo995 and ttp223.
Powered by 5v 2A with batteries

  1. The problem is that when everything turns on, I press the touch button, the code does not work.
    If you reboot the esp8266 after turning it on, the code will start working.
  2. Problem After restarting the ESP8266, the servo can be rotated with the touch button for a maximum of 3 times. Then ttp223 accepts everything, but the servo does not rotate

Do you think that it might help if you posted the code so that we could see it ? Don't forget to use code tags when you post it

Is the servo being powered from the ESP8266 or directly from the power supply ?

The servo is powered directly from the power supply. Only the GND of the servo is connected to the ESP

#include <Servo.h>
Servo bir;
void setup() {
  bir.attach(2);
  bir.write(0);
  pinMode(4, INPUT);
}

void loop() {
  if (digitalRead(4) == HIGH) {
    if (bir.read() == 0) {
      bir.write(180);
      delay(1000);


    }
  }
  if (digitalRead(4) == HIGH) {
    if (bir.read() == 180) {
      bir.write(0);
      delay(1000);
    }
  }
}

You have set pin 4 as an INPUT and are testing for HIGH on that pin to signal that the button has been touched. Have you got a pulldown resistor in the circuit keeping the input LOW when the button is not touched ?

Unfortunately, the project does not have such a thing. Please tell me what resistor value needs to be set to the ttp223 pin

A 10K resistor from the pin to GND would be a good starting point, but are you sure that the ttp223 is behaving itself and outputting what you expect it to ?

I think there is a reason for this. But I think that the most important mistake is improper nutrition.
Because when powered from a 5 V 2 A network, it works adequately.
If you connect a 5V 2.4A battery, it doesn't work after 2 times for some reason. Please tell me why this is so. Where am I wrong about something

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.