Advertisement
pan7nikt

PinControlNODE

Jan 11th, 2020
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.64 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,2,0,0,0,22,0,8,13,0,
  38.   3,3,9,2,22,59,2,26,1,0,
  39.   54,13,35,35,2,31,68,49,0 };
  40.    
  41. // this structure defines all the variables of your control interface  
  42. struct {
  43.  
  44.     // input variable
  45.   uint8_t select_1; // =0 if select position A, =1 if position B, =2 if position C, ...
  46.   uint8_t button_1; // =1 if button pressed, else =0
  47.  
  48.     // other variable
  49.   uint8_t connect_flag;  // =1 if wire connected, else =0
  50.  
  51. } RemoteXY;
  52. #pragma pack(pop)
  53.  
  54. /////////////////////////////////////////////
  55. //           END RemoteXY include          //
  56. /////////////////////////////////////////////
  57.  
  58. #define PIN_BUTTON_1 D1
  59.  
  60.  
  61. void setup()  
  62. {
  63.   RemoteXY_Init ();  
  64.    
  65.   pinMode (PIN_BUTTON_1, OUTPUT);
  66.   pinMode (D2, OUTPUT);
  67.   pinMode (D3, OUTPUT);
  68.   pinMode (D4, OUTPUT);
  69.    
  70.   // TODO you setup code
  71.    
  72. }
  73.  
  74. void loop()  
  75. {  
  76.   RemoteXY_Handler ();
  77.    
  78.   digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1==0)?LOW:HIGH);
  79.    
  80.   // TODO you loop code
  81.   // use the RemoteXY structure for data transfer
  82.  
  83.   if(RemoteXY.select_1 == 0 )
  84.   {
  85.     digitalWrite(D2, HIGH);
  86.   }
  87.   else
  88.   {
  89.     digitalWrite(D2, LOW);
  90.   }
  91.  
  92.   if(RemoteXY.select_1 == 1 )
  93.   {
  94.     digitalWrite(D3, HIGH);
  95.   }
  96.   else
  97.   {
  98.     digitalWrite(D3, LOW);
  99.   }
  100.  
  101.   if(RemoteXY.select_1 == 2 )
  102.   {
  103.     digitalWrite(D4, HIGH);
  104.   }
  105.   else
  106.   {
  107.     digitalWrite(D4, LOW);
  108.   }
  109.  
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement