Advertisement
pan7nikt

robotWiFi

Jan 11th, 2020
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.89 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 2.4.3 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.3.1 or later version;
  10.      - for iOS 1.3.5 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[] =
  37.   { 255,3,0,0,0,43,0,8,13,0,
  38.   4,0,9,1,8,61,2,26,4,0,
  39.   80,1,8,61,2,26,129,0,33,8,
  40.   25,6,17,107,105,101,114,117,110,101,
  41.   107,0,3,131,33,15,25,9,2,26 };
  42.    
  43. // this structure defines all the variables of your control interface  
  44. struct {
  45.  
  46.     // input variable
  47.   int8_t slider_left; // =0..100 slider position
  48.   int8_t slider_right; // =0..100 slider position
  49.   uint8_t kierunek_1; // =0 if select position A, =1 if position B, =2 if position C, ...
  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. int leftSl = 0;
  62. int rightSl = 0;
  63. int kierunek;
  64.  
  65. void setup()  
  66. {
  67.   RemoteXY_Init ();  
  68.    
  69.    
  70.   // TODO you setup code  
  71.   pinMode(D1, OUTPUT);
  72. pinMode(D2, OUTPUT);
  73. pinMode(D5, OUTPUT);
  74. pinMode(D6, OUTPUT);
  75. }
  76.  
  77. void loop()  
  78. {  
  79.   RemoteXY_Handler ();
  80.    kierunek = RemoteXY.kierunek_1;
  81.    leftSl = RemoteXY.slider_left;
  82.    rightSl = RemoteXY.slider_right;
  83.    
  84.   // TODO you loop code
  85.   // use the RemoteXY structure for data transfer
  86.     if (kierunek==0)
  87.   {
  88.   analogWrite(D1, LOW);
  89.   digitalWrite(D2, LOW);
  90.  
  91.   analogWrite(D5, LOW);
  92.   digitalWrite(D6, LOW);
  93.   }
  94.  
  95.   if (kierunek==1)
  96.   {
  97.   analogWrite(D1, leftSl * 10);
  98.   digitalWrite(D2, HIGH);
  99.  
  100.   analogWrite(D5, rightSl * 10);
  101.   digitalWrite(D6, HIGH);
  102.   }
  103.  
  104.   if(kierunek==2)
  105.   {
  106.   analogWrite(D2, leftSl * 10);
  107.   digitalWrite(D1, HIGH);
  108.  
  109.   analogWrite(D6, rightSl * 10);
  110.   digitalWrite(D5, HIGH);
  111.   }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement