Advertisement
pan7nikt

RobotWiFi_V2

Apr 4th, 2023
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.12 KB | None | 0 0
  1. /*
  2.    -- New project --
  3.    
  4.    This source code of graphical user interface
  5.    has been generated automatically by RemoteXY editor.
  6.    To compile this code using RemoteXY library 3.1.8 or later version
  7.    download by link http://remotexy.com/en/library/
  8.    To connect using RemoteXY mobile app by link http://remotexy.com/en/download/                  
  9.      - for ANDROID 4.11.1 or later version;
  10.      - for iOS 1.9.1 or later version;
  11.    
  12.    This source code is free software; you can redistribute it and/or
  13.    modify it under the terms of the GNU Lesser General Public
  14.    License as published by the Free Software Foundation; either
  15.    version 2.1 of the License, or (at your option) any later version.    
  16. */
  17.  
  18. //////////////////////////////////////////////
  19. //        RemoteXY include library          //
  20. //////////////////////////////////////////////
  21.  
  22. // RemoteXY select connection mode and include library
  23. #define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
  24. #include <ESP8266WiFi.h>
  25.  
  26. #include <RemoteXY.h>
  27.  
  28. // RemoteXY connection settings
  29. #define REMOTEXY_WIFI_SSID "RemoteXY"
  30. #define REMOTEXY_WIFI_PASSWORD "12345678"
  31. #define REMOTEXY_SERVER_PORT 6377
  32.  
  33.  
  34. // RemoteXY configurate  
  35. #pragma pack(push, 1)
  36. uint8_t RemoteXY_CONF[] =   // 63 bytes
  37.   { 255,4,0,0,0,56,0,16,13,0,4,0,9,1,8,61,2,26,4,0,
  38.   80,1,8,61,2,26,2,0,35,15,22,11,2,26,31,31,112,114,122,111,
  39.   100,0,116,121,108,0,2,0,35,42,22,11,35,26,31,31,79,78,0,79,
  40.   70,70,0 };
  41.  
  42. // this structure defines all the variables and events of your control interface
  43. struct {
  44.  
  45.     // input variables
  46.   int8_t slider_left; // =0..100 slider position
  47.   int8_t slider_right; // =0..100 slider position
  48.   uint8_t switch_1; // =1 if switch ON and =0 if OFF
  49.   uint8_t switch_2; // =1 if switch ON and =0 if OFF
  50.  
  51.     // other variable
  52.   uint8_t connect_flag;  // =1 if wire connected, else =0
  53.  
  54. } RemoteXY;
  55. #pragma pack(pop)
  56.  
  57. /////////////////////////////////////////////
  58. //           END RemoteXY include          //
  59. /////////////////////////////////////////////
  60.  
  61.  
  62.  
  63. int leftSl = 0;
  64.   int rightSl = 0;
  65.   int kierunek;
  66.   int power;
  67.  
  68. void setup()
  69. {
  70.   RemoteXY_Init ();  
  71.    
  72.    
  73.   // TODO you setup code  
  74.   pinMode(D1, OUTPUT);
  75. pinMode(D2, OUTPUT);
  76. pinMode(D5, OUTPUT);
  77. pinMode(D6, OUTPUT);
  78. Serial.begin(9600);
  79.  
  80.  
  81.   // TODO you setup code
  82.  
  83. }
  84.  
  85. void loop()
  86. {
  87.   RemoteXY_Handler ();
  88.  
  89.   RemoteXY_Handler ();
  90.    kierunek = RemoteXY.switch_1;
  91.    power = RemoteXY.switch_2;
  92.    leftSl = map(RemoteXY.slider_left,0,100,0,255);
  93.    rightSl = map(RemoteXY.slider_right,0,100,0,255);
  94.    
  95.   // TODO you loop code
  96.   // use the RemoteXY structure for data transfer
  97.     if (power == 0)
  98.   {
  99.   analogWrite(D1, LOW);
  100.   digitalWrite(D2, LOW);
  101.  
  102.   analogWrite(D5, LOW);
  103.   digitalWrite(D6, LOW);
  104.   }
  105.  
  106.   if (kierunek==0 && power == 1)
  107.   {
  108.   analogWrite(D1, leftSl);
  109.   digitalWrite(D2, HIGH);
  110.  
  111.   analogWrite(D5, rightSl);
  112.   digitalWrite(D6, HIGH);
  113.   }
  114.  
  115.   if(kierunek==1 && power == 1)
  116.   {
  117.   analogWrite(D2, leftSl);
  118.   digitalWrite(D1, HIGH);
  119.  
  120.   analogWrite(D6, rightSl);
  121.   digitalWrite(D5, HIGH);}
  122.  
  123.   Serial.println(leftSl);
  124.  
  125.  
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement