<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Помогите пожалуйста поправить код]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1926&amp;type=atom" />
	<updated>2025-02-08T20:52:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=1926</id>
		<entry>
			<title type="html"><![CDATA[Помогите пожалуйста поправить код]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=5885#p5885" />
			<content type="html"><![CDATA[<p>Доброго времени суток!!!</p><p>Недавно начал осваивать программирование, не могу разобраться с библиотекой ESP8266Ping.h помогите пожалуйста дополнить код возможностью пинговать подключенный WiFi выводить на эран показания пинга&nbsp; в int8_t Ping и при высоком пинге (более 100) включать strings_01 (сообщение) и led_01 (индикатор)</p><br /><br /><p>ЗАРАНЕЕ ОЧЕНЬ СИЛЬНО БЛАГОДАРЕН!!!!</p><br /><p>Вот скетч:</p><div class="codebox"><pre><code>#define REMOTEXY_MODE__WIFI_CLOUD

// настройки соединения
#define REMOTEXY_WIFI_SSID &quot;Xiaomi_A95D&quot;
#define REMOTEXY_WIFI_PASSWORD &quot;****&quot;
#define REMOTEXY_CLOUD_SERVER &quot;cloud.remotexy.com&quot;
#define REMOTEXY_CLOUD_PORT 6376
#define REMOTEXY_CLOUD_TOKEN &quot;*****&quot;
#define REMOTEXY_ACCESS_PASSWORD &quot;*******&quot;

#include &lt;SoftwareSerial.h&gt;
#include &lt;TinyGPS++.h&gt;
#include &lt;ESP8266WiFi.h&gt;
#include &lt;ESP8266Ping.h&gt;

// Define the RX and TX pins for Software Serial 2
#define RX 12
#define TX 14

#define GPS_BAUD 9600

// The TinyGPS++ object
TinyGPSPlus gps;

// Create an instance of Software Serial
SoftwareSerial gpsSerial(RX, TX);

#include &lt;RemoteXY.h&gt;

// конфигурация интерфейса RemoteXY
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =  // 213 bytes
  { 255, 3, 0, 18, 0, 206, 0, 19, 0, 0, 0, 75, 97, 116, 101, 114, 0, 0, 1, 200,
    84, 1, 1, 13, 0, 5, 127, 7, 68, 68, 35, 1, 26, 31, 73, 3, 3, 7, 17, 4,
    128, 0, 2, 26, 0, 0, 0, 0, 0, 0, 200, 66, 0, 0, 0, 0, 67, 0, 61, 72,
    9, 78, 2, 26, 7, 67, 0, 73, 72, 9, 78, 2, 26, 7, 129, 1, 62, 30, 8, 64,
    2, 208, 168, 208, 184, 209, 128, 208, 190, 209, 130, 208, 176, 0, 129, 1, 74, 32, 8, 64,
    2, 208, 148, 208, 190, 208, 187, 208, 179, 208, 190, 209, 130, 208, 176, 0, 67, 0, 50, 72,
    9, 94, 2, 26, 129, 1, 51, 34, 8, 64, 2, 87, 105, 70, 105, 32, 100, 66, 109, 0,
    70, 82, 2, 20, 20, 16, 134, 37, 0, 1, 81, 54, 24, 24, 0, 187, 31, 82, 101, 98,
    111, 111, 116, 0, 72, 17, 1, 31, 31, 12, 166, 163, 2, 26, 0, 0, 0, 0, 0, 0,
    200, 66, 0, 0, 0, 0, 74, 72, 23, 42, 10, 9, 2, 0, 37, 67, 76, 111, 119, 32,
    115, 105, 103, 110, 97, 108, 0, 69, 103, 1, 7, 7, 1 };

// структура определяет все переменные и события вашего интерфейса управления
struct {

  // input variables
  int8_t joystick_01_x;  // oт -100 до 100
  int8_t joystick_01_y;  // oт -100 до 100
  uint8_t button_01;     // =1 если кнопка нажата, иначе =0

  // output variables
  float linearbar_01;  // oт 0 до 100
  float Lat;
  float Long;
  int8_t Ping;  // -128 .. 127
  uint8_t led_01;         // oт 0 до 1 индикатор низкого сигнала Wifi
  int8_t circularBar_01;  // oт 0 до 100 уровень сигнала строка
  uint8_t strings_01;     // oт 0 до 1 сообщение о низком сигнале Wifi
  int16_t sound_01;       // =0 нет звука, иначе ID звука, для примера 1001, смотри список звуков в приложении
 
    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0
  
  const char* domain = &quot;Xiaomi_A95D&quot;;
  
} RemoteXY;
#pragma pack(pop)

/* определяем пины управления правым мотором */

#define PIN_MOTOR_RIGHT_UP D7  // на пин IN1
#define PIN_MOTOR_RIGHT_DN D8  // IN2
//#define PIN_MOTOR_RIGHT_SPEED D8 //ENA Удалить

/* определяем пины управления левым мотором */

#define PIN_MOTOR_LEFT_UP D3  // на пин IN3
#define PIN_MOTOR_LEFT_DN D4  // IN4
//#define PIN_MOTOR_LEFT_SPEED D3 //ENB Удалить

/* определяем пин управления светодиодом */

//#define PIN_LED D5

/* определяем два массива с перечислением пинов для каждого мотора */

unsigned char RightMotor[3] = { PIN_MOTOR_RIGHT_UP, PIN_MOTOR_RIGHT_DN };
unsigned char LeftMotor[3] = { PIN_MOTOR_LEFT_UP, PIN_MOTOR_LEFT_DN };

void Wheel(unsigned char* motor, int v)

{

  if (v &gt; 100) v = 100;
  if (v &lt; -100) v = -100;
  if (v &gt; 0) {

    digitalWrite(motor[0], HIGH);
    digitalWrite(motor[1], LOW);
    //analogWrite(motor[2], v*2.55);

  }

  else if (v &lt; 0) {

    digitalWrite(motor[0], LOW);
    digitalWrite(motor[1], HIGH);
    //analogWrite(motor[2], (-v)*2.55);

  }

  else {

    digitalWrite(motor[0], LOW);
    digitalWrite(motor[1], LOW);
    //analogWrite(motor[2], 0);
  }
}



void setup() {

  RemoteXY_Init();

  // Set WiFi to Station Mode ДЛЯ WIFI
  WiFi.mode(WIFI_STA);

  // для Wifi Connect to WiFi
  WiFi.begin(REMOTEXY_WIFI_SSID, REMOTEXY_WIFI_PASSWORD);
  RemoteXY_delay(10);
  // для Wifi Check if connected to WiFi
  while (WiFi.status() != WL_CONNECTED)
    RemoteXY_delay(500);


  /* инициализация пинов */

  pinMode(PIN_MOTOR_RIGHT_UP, OUTPUT);
  pinMode(PIN_MOTOR_RIGHT_DN, OUTPUT);
  pinMode(PIN_MOTOR_LEFT_UP, OUTPUT);
  pinMode(PIN_MOTOR_LEFT_DN, OUTPUT);
  //pinMode (PIN_LED, OUTPUT);

  // Serial Monitor
  Serial.begin(115200);



  // TODO you setup code
  // Start Serial 2 with the defined RX and TX pins and a baud rate of 9600
  gpsSerial.begin(GPS_BAUD);
  //Serial.println(&quot;Software Serial started at 9600 baud rate&quot;);

    


}



void loop() {
  RemoteXY_Handler();


  // TODO you loop code
  // используйте структуру RemoteXY для передачи данных
  // не используйте функцию delay(), вместо нее используйте RemoteXY_delay()
  // This sketch displays information every time a new sentence is correctly encoded.



   {
    /* управляем правым мотором */
    Wheel(RightMotor, RemoteXY.joystick_01_x + RemoteXY.joystick_01_y);

    /* управляем левым мотором */
    Wheel(LeftMotor, RemoteXY.joystick_01_x - RemoteXY.joystick_01_y);
  }


  unsigned long start = millis();

  while (millis() - start &lt; 1000) {
    while (gpsSerial.available() &gt; 0) {
      gps.encode(gpsSerial.read());
    }
    if (gps.location.isUpdated()) {

      float Lat = gps.location.lat();
      float Long = gps.location.lng();
      //float Speed = gps.speed.kmph();
      RemoteXY.Lat = Lat;
      RemoteXY.Long = Long;
      


//RemoteXY.RSSI = WiFi.RSSI();
      
     
     
    }
  }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[scherban.alexey]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=3001</uri>
			</author>
			<updated>2025-02-08T20:52:15Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=5885#p5885</id>
		</entry>
</feed>
